Added checks to panic if VFS functions are passed NULL pointers. This
may expose some bugs that have been lurking about. Checks can be
easily removed later.
(This used to be commit
c33c6330e3a2025f2fda0234635dfdd3acd04890)
+/* Check for NULL pointer parameters in vfswrap_* functions */
+
+#define VFS_CHECK_NULL
+
/* We don't want to have NULL function pointers lying around. Someone
is sure to try and execute them. These stubs are used to prevent
this possibility. */
/* We don't want to have NULL function pointers lying around. Someone
is sure to try and execute them. These stubs are used to prevent
this possibility. */
int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service,
char *user)
{
int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service,
char *user)
{
+ return 0; /* Return >= 0 for success */
}
void vfswrap_dummy_disconnect(void)
{
}
void vfswrap_dummy_disconnect(void)
{
- /* Do nothing a bit more */
+#ifdef VFS_CHECK_NULL
+ if ((path == NULL) || (bsize == NULL) || (dfree == NULL) ||
+ (dsize == NULL)) {
+
+ smb_panic("NULL pointer passed to vfswrap_disk_free() function\n");
+ }
+#endif
+
result = sys_disk_free(path, bsize, dfree, dsize);
return result;
}
result = sys_disk_free(path, bsize, dfree, dsize);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (fname == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_opendir()\n");
+ }
+#endif
+
result = opendir(fname);
return result;
}
result = opendir(fname);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (dirp == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_readdir()\n");
+ }
+#endif
+
result = readdir(dirp);
return result;
}
result = readdir(dirp);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (path == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_mkdir()\n");
+ }
+#endif
+
result = mkdir(path, mode);
return result;
}
result = mkdir(path, mode);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (path == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_rmdir()\n");
+ }
+#endif
+
result = rmdir(path);
return result;
}
result = rmdir(path);
return result;
}
int vfswrap_closedir(DIR *dirp)
{
int result;
int vfswrap_closedir(DIR *dirp)
{
int result;
+
+#ifdef VFS_CHECK_NULL
+ if (dirp == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_closedir()\n");
+ }
+#endif
+
result = closedir(dirp);
return result;
}
result = closedir(dirp);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (fname == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_open()\n");
+ }
+#endif
+
result = sys_open(fname, flags, mode);
return result;
}
result = sys_open(fname, flags, mode);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (data == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_read()\n");
+ }
+#endif
+
result = read(fd, data, n);
return result;
}
result = read(fd, data, n);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (data == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_write()\n");
+ }
+#endif
+
result = write(fd, data, n);
return result;
}
result = write(fd, data, n);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if ((old == NULL) || (new == NULL)) {
+ smb_panic("NULL pointer passed to vfswrap_rename()\n");
+ }
+#endif
+
result = rename(old, new);
return result;
}
result = rename(old, new);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if ((fname == NULL) || (sbuf == NULL)) {
+ smb_panic("NULL pointer passed to vfswrap_stat()\n");
+ }
+#endif
+
result = sys_stat(fname, sbuf);
return result;
}
result = sys_stat(fname, sbuf);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (sbuf == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_fstat()\n");
+ }
+#endif
+
result = sys_fstat(fd, sbuf);
return result;
}
result = sys_fstat(fd, sbuf);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if ((path == NULL) || (sbuf == NULL)) {
+ smb_panic("NULL pointer passed to vfswrap_lstat()\n");
+ }
+#endif
+
result = sys_lstat(path, sbuf);
return result;
}
result = sys_lstat(path, sbuf);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (path == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_unlink()\n");
+ }
+#endif
+
result = unlink(path);
return result;
}
result = unlink(path);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if (path == NULL) {
+ smb_panic("NULL pointer passed to vfswrap_chmod()\n");
+ }
+#endif
+
result = chmod(path, mode);
return result;
}
result = chmod(path, mode);
return result;
}
+#ifdef VFS_CHECK_NULL
+ if ((path == NULL) || (times == NULL)) {
+ smb_panic("NULL pointer passed to vfswrap_utime()\n");
+ }
+#endif
+
result = utime(path, times);
return result;
}
result = utime(path, times);
return result;
}