[SCM] Samba Shared Repository - branch v3-6-test updated
Jeremy Allison
jra at samba.org
Fri Sep 10 12:56:29 MDT 2010
The branch, v3-6-test has been updated
via e0750f2 Check all SMB_MALLOC returns correctly. Found by Andreas Moroder <andreas.moroder at gmx.net>.
from d870915 s3:torture: fix printf output, lines can't start with lower case "test"
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test
- Log -----------------------------------------------------------------
commit e0750f2b8f371a7c84bc4bc9ba91bd4ebc47e580
Author: Jeremy Allison <jra at samba.org>
Date: Fri Sep 10 11:56:26 2010 -0700
Check all SMB_MALLOC returns correctly. Found by Andreas Moroder <andreas.moroder at gmx.net>.
Jeremy
(cherry picked from commit e8509589287ea04c6290dd127d3ef0c3e0b3f49d)
-----------------------------------------------------------------------
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
More information about the samba-cvs
mailing list