summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-28 00:50:14 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:19:01 -0500
commitd1014c1cdfce116741ddd6eccd65b69530ce0b84 (patch)
tree04ba00b02632484f2492f979229b76e06bc92141 /source3/printing
parent5a1a08d4286b85252233517373cad75a355b05a7 (diff)
downloadsamba-d1014c1cdfce116741ddd6eccd65b69530ce0b84.tar.gz
samba-d1014c1cdfce116741ddd6eccd65b69530ce0b84.tar.bz2
samba-d1014c1cdfce116741ddd6eccd65b69530ce0b84.zip
r16582: Fix Klocwork #1997 and all generic class of problems
where we don't correctly check the return from memdup. Jeremy. (This used to be commit ce14daf51c7ee2f9c68c77f7f4674e6f0e35c9ca)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 5c4039722e..85b7513c62 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -738,6 +738,9 @@ uint32 get_c_setprinter(void)
int get_builtin_ntforms(nt_forms_struct **list)
{
*list = (nt_forms_struct *)memdup(&default_forms[0], sizeof(default_forms));
+ if (!*list) {
+ return 0;
+ }
return sizeof(default_forms) / sizeof(default_forms[0]);
}
@@ -2078,6 +2081,10 @@ static WERROR get_a_printer_driver_3_default(NT_PRINTER_DRIVER_INFO_LEVEL_3 **in
fstrcpy(info.dependentfiles[0], "");
*info_ptr = memdup(&info, sizeof(info));
+ if (!*info_ptr) {
+ SAFE_FREE(info.dependentfiles);
+ return WERR_NOMEM;
+ }
return WERR_OK;
}
@@ -2152,6 +2159,10 @@ static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr,
}
*info_ptr = (NT_PRINTER_DRIVER_INFO_LEVEL_3 *)memdup(&driver, sizeof(driver));
+ if (!*info_ptr) {
+ SAFE_FREE(driver.dependentfiles);
+ return WERR_NOMEM;
+ }
return WERR_OK;
}
@@ -2652,6 +2663,10 @@ int unpack_devicemode(NT_DEVICEMODE **nt_devmode, char *buf, int buflen)
}
*nt_devmode = (NT_DEVICEMODE *)memdup(&devmode, sizeof(devmode));
+ if (!*nt_devmode) {
+ SAFE_FREE(devmode.nt_dev_private);
+ return -1;
+ }
DEBUG(8,("Unpacked devicemode [%s](%s)\n", devmode.devicename, devmode.formname));
if (devmode.nt_dev_private)