diff options
author | Volker Lendecke <vlendec@samba.org> | 2005-04-26 12:26:32 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:56:42 -0500 |
commit | ce8dee5c3c3aef931ee6aae6feec9d87fa1a1dde (patch) | |
tree | 32def61eeb0b98c0735db2f490e096b1b4b5af17 | |
parent | 7522810acbd4cda990ef17bf5db29656fd4a32b2 (diff) | |
download | samba-ce8dee5c3c3aef931ee6aae6feec9d87fa1a1dde.tar.gz samba-ce8dee5c3c3aef931ee6aae6feec9d87fa1a1dde.tar.bz2 samba-ce8dee5c3c3aef931ee6aae6feec9d87fa1a1dde.zip |
r6488: net rpc printer migrate should not try to set stuff that's not there. This
fixes two segfaults. Thanks to Karolin Segger <ks@sernet.de> to find the bug
and test the patch.
Volker
(This used to be commit 5fa5454218acf9975578dee1386d530f09ac7339)
-rw-r--r-- | source3/utils/net_rpc_printer.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 9f5730994e..b348c2b4e8 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -1960,6 +1960,12 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid, const } + if (strlen(drivername) == 0) { + DEBUGADD(1,("Did not get driver for printer %s\n", + printername)); + goto done; + } + /* setdriver dst */ init_unistr(&info_ctr_dst.printers_2->drivername, drivername); @@ -2297,28 +2303,34 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const DEBUG(3,("republished printer\n")); } - /* copy devmode (info level 2) */ - ctr_dst.printers_2->devmode = TALLOC_MEMDUP(mem_ctx, - ctr_enum.printers_2[i].devmode, sizeof(DEVICEMODE)); + if (ctr_enum.printers_2[i].devmode != NULL) { + + /* copy devmode (info level 2) */ + ctr_dst.printers_2->devmode = + TALLOC_MEMDUP(mem_ctx, + ctr_enum.printers_2[i].devmode, + sizeof(DEVICEMODE)); - /* do not copy security descriptor (we have another command for that) */ - ctr_dst.printers_2->secdesc = NULL; + /* do not copy security descriptor (we have another + * command for that) */ + ctr_dst.printers_2->secdesc = NULL; #if 0 - if (asprintf(&devicename, "\\\\%s\\%s", longname, printername) < 0) { - nt_status = NT_STATUS_NO_MEMORY; - goto done; - } + if (asprintf(&devicename, "\\\\%s\\%s", longname, + printername) < 0) { + nt_status = NT_STATUS_NO_MEMORY; + goto done; + } - init_unistr(&ctr_dst.printers_2->devmode->devicename, devicename); + init_unistr(&ctr_dst.printers_2->devmode->devicename, + devicename); #endif - if (!net_spoolss_setprinter(cli_dst, mem_ctx, &hnd_dst, - level, &ctr_dst)) - goto done; + if (!net_spoolss_setprinter(cli_dst, mem_ctx, &hnd_dst, + level, &ctr_dst)) + goto done; - DEBUGADD(1,("\tSetPrinter of DEVICEMODE succeeded\n")); - - + DEBUGADD(1,("\tSetPrinter of DEVICEMODE succeeded\n")); + } /* STEP 2: COPY REGISTRY VALUES */ |