diff options
-rw-r--r-- | source3/modules/vfs_dirsort.c | 18 | ||||
-rw-r--r-- | source3/utils/smbget.c | 3 |
2 files changed, 18 insertions, 3 deletions
diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c index d96aca0cb1..4869bc05a0 100644 --- a/source3/modules/vfs_dirsort.c +++ b/source3/modules/vfs_dirsort.c @@ -43,14 +43,15 @@ static void free_dirsort_privates(void **datap) { return; } -static void open_and_sort_dir (vfs_handle_struct *handle) +static bool open_and_sort_dir (vfs_handle_struct *handle) { SMB_STRUCT_DIRENT *dp; struct stat dir_stat; long current_pos; struct dirsort_privates *data = NULL; - SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, return); + SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, + return false); data->number_of_entries = 0; @@ -71,6 +72,9 @@ static void open_and_sort_dir (vfs_handle_struct *handle) SAFE_FREE(data->directory_list); /* destroy previous cache if needed */ data->directory_list = (SMB_STRUCT_DIRENT *)SMB_MALLOC( data->number_of_entries * sizeof(SMB_STRUCT_DIRENT)); + if (!data->directory_list) { + return false; + } current_pos = data->pos; data->pos = 0; while ((dp = SMB_VFS_NEXT_READDIR(handle, data->source_directory, @@ -81,6 +85,7 @@ static void open_and_sort_dir (vfs_handle_struct *handle) /* Sort the directory entries by name */ data->pos = current_pos; TYPESAFE_QSORT(data->directory_list, data->number_of_entries, compare_dirent); + return true; } static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle, @@ -93,6 +98,10 @@ static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle, data = (struct dirsort_privates *)SMB_MALLOC( sizeof(struct dirsort_privates)); + if (!data) { + return NULL; + } + data->directory_list = NULL; data->pos = 0; @@ -105,7 +114,10 @@ static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle, SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates, struct dirsort_privates, return NULL); - open_and_sort_dir(handle); + if (!open_and_sort_dir(handle)) { + SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory); + return NULL; + } return data->source_directory; } diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c index 02ce46ee97..f09c2f6530 100644 --- a/source3/utils/smbget.c +++ b/source3/utils/smbget.c @@ -442,6 +442,9 @@ static int smb_download_file(const char *base, const char *name, int recursive, } readbuf = (char *)SMB_MALLOC(blocksize); + if (!readbuf) { + return 1; + } /* Now, download all bytes from offset_download to the end */ for(curpos = offset_download; curpos < remotestat.st_size; curpos+=blocksize) { |