From 79bfb14318423f5a26a4d0dc6fc6faa62b1401f8 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 13 Mar 2000 11:09:20 +0000 Subject: parse correctly getprinterdriver2 found a stupid bug in enumprinters fixed some memleaks found a coredump in enumprinterdata getprinterdriverdir responds correctly now. J.F. (This used to be commit 07f2e194ba61e72320636fb7e5d0f041e255868b) --- source3/rpc_server/srv_spoolss.c | 5 ++- source3/rpc_server/srv_spoolss_nt.c | 85 +++++++++++++++++++------------------ 2 files changed, 46 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 75493b7a30..1cf187d825 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -286,9 +286,10 @@ static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_str /* that's an [in out] buffer */ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level, q_u.unknown, + r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level, + q_u.clientmajorversion, q_u.clientminorversion, r_u.buffer, q_u.offered, - &r_u.needed, &r_u.unknown0, &r_u.unknown1); + &r_u.needed, &r_u.servermajorversion, &r_u.serverminorversion); if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ef0b7fad9b..d0fc839154 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1991,19 +1991,15 @@ static uint32 enumprinters_level2( uint32 flags, fstring servername, fstrcat(temp, global_myname); if (flags & PRINTER_ENUM_LOCAL) { - if (!strcmp(servername, temp)) { - fstrcat(temp, "\\"); + if (!strcmp(servername, temp)) return enum_all_printers_info_2(temp, buffer, offered, needed, returned); - } else return enum_all_printers_info_2("", buffer, offered, needed, returned); } if (flags & PRINTER_ENUM_NAME) { - if (!strcmp(servername, temp)) { - fstrcat(temp, "\\"); + if (!strcmp(servername, temp)) return enum_all_printers_info_2(temp, buffer, offered, needed, returned); - } else return ERROR_INVALID_NAME; } @@ -2055,6 +2051,7 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le */ unistr2_to_ascii(name, servername, sizeof(name)-1); + strupper(name); switch (level) { case 1: @@ -2391,8 +2388,10 @@ static uint32 getprinterdriver2_level1(pstring servername, pstring architecture, /* check the required size. */ *needed += spoolss_size_printer_driver_info_1(info); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_driver_info_1("", buffer, info, 0); @@ -2400,9 +2399,8 @@ static uint32 getprinterdriver2_level1(pstring servername, pstring architecture, /* clear memory */ safe_free(info); - if (*needed > offered) { + if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; - } else return NT_STATUS_NO_PROBLEMO; } @@ -2420,8 +2418,10 @@ static uint32 getprinterdriver2_level2(pstring servername, pstring architecture, /* check the required size. */ *needed += spoolss_size_printer_driver_info_2(info); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_driver_info_2("", buffer, info, 0); @@ -2429,9 +2429,8 @@ static uint32 getprinterdriver2_level2(pstring servername, pstring architecture, /* clear memory */ safe_free(info); - if (*needed > offered) { + if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; - } else return NT_STATUS_NO_PROBLEMO; } @@ -2449,8 +2448,10 @@ static uint32 getprinterdriver2_level3(pstring servername, pstring architecture, /* check the required size. */ *needed += spoolss_size_printer_driver_info_3(info); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_driver_info_3("", buffer, info, 0); @@ -2458,18 +2459,18 @@ static uint32 getprinterdriver2_level3(pstring servername, pstring architecture, /* clear memory */ safe_free(info); - if (*needed > offered) { + if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; - } else return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, uint32 unknown, +uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, + uint32 clientmajorversion, uint32 clientminorversion, NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *unknown0, uint32 *unknown1) + uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion) { pstring servername; fstring architecture; @@ -2478,16 +2479,14 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a DEBUG(4,("_spoolss_getprinterdriver2\n")); *needed=0; - *unknown0=0; - *unknown1=0; + *servermajorversion=0; + *serverminorversion=0; pstrcpy(servername, global_myname); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); if (!get_printer_snum(handle, &snum)) - { return NT_STATUS_INVALID_HANDLE; - } switch (level) { case 1: @@ -3381,8 +3380,10 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, *needed=buffer_size; - if (!alloc_buffer_size(buffer, buffer_size)) + if (!alloc_buffer_size(buffer, buffer_size)){ + safe_free(list); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the form structures */ for (i=0; i<*numofforms; i++) @@ -3400,7 +3401,7 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, default: safe_free(list); - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_INVALID_LEVEL; } } @@ -3441,8 +3442,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need ports=(PORT_INFO_1 *)malloc( (*returned+1) * sizeof(PORT_INFO_1) ); - for (snum=0; snum