The branch, master has been updated
       via  e850958 Check all SMB_MALLOC returns correctly. Found by Andreas 
Moroder <andreas.moro...@gmx.net>.
      from  55598c4 s4:torture/rpc/winreg.c - hopefully this attempt fixes 
Solaris "cc" on the buildfarm

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e8509589287ea04c6290dd127d3ef0c3e0b3f49d
Author: Jeremy Allison <j...@samba.org>
Date:   Fri Sep 10 11:56:26 2010 -0700

    Check all SMB_MALLOC returns correctly. Found by Andreas Moroder 
<andreas.moro...@gmx.net>.
    
    Jeremy

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_dirsort.c |   18 +++++++++++++++---
 source3/utils/smbget.c        |    3 +++
 2 files changed, 18 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c
index d96aca0..4869bc0 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 02ce46e..f09c2f6 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) {


-- 
Samba Shared Repository

Reply via email to