diff options
author | Jeremy Allison <jra@samba.org> | 2006-06-28 00:50:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:19:01 -0500 |
commit | ce14daf51c7ee2f9c68c77f7f4674e6f0e35c9ca (patch) | |
tree | 4410f844e5f7b83ef3e1bb796027b0e98a11d2aa /source/printing | |
parent | 6967fd4cefa84a7b7b5e14467bfa8152907d55c9 (diff) | |
download | samba-ce14daf51c7ee2f9c68c77f7f4674e6f0e35c9ca.tar.gz samba-ce14daf51c7ee2f9c68c77f7f4674e6f0e35c9ca.tar.xz samba-ce14daf51c7ee2f9c68c77f7f4674e6f0e35c9ca.zip |
r16582: Fix Klocwork #1997 and all generic class of problems
where we don't correctly check the return from memdup.
Jeremy.
Diffstat (limited to 'source/printing')
-rw-r--r-- | source/printing/nt_printing.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c index 5c4039722e1..85b7513c621 100644 --- a/source/printing/nt_printing.c +++ b/source/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) |