diff options
author | Tim Potter <tpot@samba.org> | 1999-05-06 23:52:00 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 1999-05-06 23:52:00 +0000 |
commit | 798fdf4fd838cd361968debb56aaba2006f5bed1 (patch) | |
tree | 12020e26eba07511711b0cac5413187def20f337 /source3/smbd/vfs-wrap.c | |
parent | 48c3765a9884ffa9cf8ff2e9f1412b027c2b18ee (diff) | |
download | samba-798fdf4fd838cd361968debb56aaba2006f5bed1.tar.gz samba-798fdf4fd838cd361968debb56aaba2006f5bed1.tar.xz samba-798fdf4fd838cd361968debb56aaba2006f5bed1.zip |
Fix compiler warning.
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)
Diffstat (limited to 'source3/smbd/vfs-wrap.c')
-rw-r--r-- | source3/smbd/vfs-wrap.c | 107 |
1 files changed, 104 insertions, 3 deletions
diff --git a/source3/smbd/vfs-wrap.c b/source3/smbd/vfs-wrap.c index 2e25a2540b..3493c23178 100644 --- a/source3/smbd/vfs-wrap.c +++ b/source3/smbd/vfs-wrap.c @@ -21,6 +21,10 @@ #include "includes.h" +/* 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. */ @@ -28,12 +32,11 @@ int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service, char *user) { - /* Do nothing */ + return 0; /* Return >= 0 for success */ } void vfswrap_dummy_disconnect(void) { - /* Do nothing a bit more */ } /* Disk operations */ @@ -43,6 +46,14 @@ SMB_BIG_UINT vfswrap_disk_free(char *path, SMB_BIG_UINT *bsize, { SMB_BIG_UINT result; +#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; } @@ -53,6 +64,12 @@ DIR *vfswrap_opendir(char *fname) { DIR *result; +#ifdef VFS_CHECK_NULL + if (fname == NULL) { + smb_panic("NULL pointer passed to vfswrap_opendir()\n"); + } +#endif + result = opendir(fname); return result; } @@ -61,6 +78,12 @@ struct dirent *vfswrap_readdir(DIR *dirp) { struct dirent *result; +#ifdef VFS_CHECK_NULL + if (dirp == NULL) { + smb_panic("NULL pointer passed to vfswrap_readdir()\n"); + } +#endif + result = readdir(dirp); return result; } @@ -69,6 +92,12 @@ int vfswrap_mkdir(char *path, mode_t mode) { int result; +#ifdef VFS_CHECK_NULL + if (path == NULL) { + smb_panic("NULL pointer passed to vfswrap_mkdir()\n"); + } +#endif + result = mkdir(path, mode); return result; } @@ -77,6 +106,12 @@ int vfswrap_rmdir(char *path) { int result; +#ifdef VFS_CHECK_NULL + if (path == NULL) { + smb_panic("NULL pointer passed to vfswrap_rmdir()\n"); + } +#endif + result = rmdir(path); return result; } @@ -84,7 +119,13 @@ int vfswrap_rmdir(char *path) 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; } @@ -95,6 +136,12 @@ int vfswrap_open(char *fname, int flags, mode_t mode) { int 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; } @@ -111,6 +158,12 @@ ssize_t vfswrap_read(int fd, char *data, size_t n) { ssize_t 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; } @@ -119,6 +172,12 @@ ssize_t vfswrap_write(int fd, char *data, size_t n) { ssize_t 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; } @@ -135,6 +194,12 @@ int vfswrap_rename(char *old, char *new) { int 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; } @@ -148,6 +213,12 @@ int vfswrap_stat(char *fname, SMB_STRUCT_STAT *sbuf) { int 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; } @@ -156,6 +227,12 @@ int vfswrap_fstat(int fd, SMB_STRUCT_STAT *sbuf) { int 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; } @@ -165,6 +242,12 @@ int vfswrap_lstat(char *path, { int 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; } @@ -182,6 +265,12 @@ int vfswrap_unlink(char *path) { int result; +#ifdef VFS_CHECK_NULL + if (path == NULL) { + smb_panic("NULL pointer passed to vfswrap_unlink()\n"); + } +#endif + result = unlink(path); return result; } @@ -190,6 +279,12 @@ int vfswrap_chmod(char *path, mode_t mode) { int result; +#ifdef VFS_CHECK_NULL + if (path == NULL) { + smb_panic("NULL pointer passed to vfswrap_chmod()\n"); + } +#endif + result = chmod(path, mode); return result; } @@ -198,6 +293,12 @@ int vfswrap_utime(char *path, struct utimbuf *times) { int 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; } |