diff options
author | Jeremy Allison <jra@samba.org> | 2000-06-02 18:38:49 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-06-02 18:38:49 +0000 |
commit | 01c4ecd2343a4c87a0f023cd58382bf08610304e (patch) | |
tree | 2a92cc775386161f9d93bbe0e6d4bcf6ff355b59 /source3/rpc_server | |
parent | 8ff6458a3e568e759969fd1a9c827c4b47008cfb (diff) | |
download | samba-01c4ecd2343a4c87a0f023cd58382bf08610304e.tar.gz samba-01c4ecd2343a4c87a0f023cd58382bf08610304e.tar.bz2 samba-01c4ecd2343a4c87a0f023cd58382bf08610304e.zip |
Fixed null pointer indirect in addprinterex. Still working on problem
with extra directory layer in NT drivers.
Jeremy.
(This used to be commit 48a80318269c832e702678237e86ba55c10444f1)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b77deca158..e88aa9fa72 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -560,7 +560,7 @@ static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, { switch (level) { case 2: - uni_2_asc_printer_info_2(uni->info_2, &(printer->info_2)); + uni_2_asc_printer_info_2(uni->info_2, &printer->info_2); break; default: break; @@ -3793,13 +3793,16 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, fstring name; fstring share_name; + if ((printer = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL))) == NULL) { + DEBUG(0,("spoolss_addprinterex_level_2: malloc fail.\n")); + return ERROR_NOT_ENOUGH_MEMORY; + } + + ZERO_STRUCTP(printer); + clear_handle(handle); - /* NULLify info_2 here */ - /* don't put it in convert_printer_info as it's used also with non-NULL values */ - printer->info_2=NULL; - - /* convert from UNICODE to ASCII */ + /* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/ convert_printer_info(info, printer, 2); unistr2_to_ascii(share_name, &info->info_2->printername, sizeof(share_name)-1); @@ -3807,23 +3810,28 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, share_name); /* write the ASCII on disk */ - if (add_a_printer(*printer, 2) != 0x0) + if (add_a_printer(*printer, 2) != 0) { + free_a_printer(&printer,2); return ERROR_ACCESS_DENIED; + } create_printer_hnd(handle); open_printer_hnd(handle); if (!set_printer_hnd_printertype(handle, name)) { + free_a_printer(&printer,2); close_printer_handle(handle); return ERROR_ACCESS_DENIED; } if (!set_printer_hnd_printername(handle, name)) { + free_a_printer(&printer,2); close_printer_handle(handle); return ERROR_ACCESS_DENIED; } + free_a_printer(&printer,2); return NT_STATUS_NO_PROBLEMO; } @@ -3862,6 +3870,7 @@ static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint pstring path_old; pstring path_new; pstring short_archi; + pstring model_name; /* find_service is an smbd-specific function call */ int snum = find_service("print$"); @@ -3885,7 +3894,11 @@ static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint slprintf(path_old, sizeof(path_old)-1, "%s/%s/TMP_%u", lp_pathname(snum), short_archi, (unsigned int)sys_getpid()); - slprintf(path_new, sizeof(path_new)-1, "%s/%s/%s", lp_pathname(snum), short_archi, model); + + /* Clean up any '/' and other characters in the model name. */ + alpha_strcpy(model_name, model, sizeof(pstring)); + + slprintf(path_new, sizeof(path_new)-1, "%s/%s/%s", lp_pathname(snum), short_archi, model_name); DEBUG(10,("modify_driver_heirarchy: old_path=%s, new_path=%s\n", path_old, path_new )); |