diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/printing/nt_printing.c | 2 | ||||
-rw-r--r-- | source3/rpc_parse/parse_spoolss.c | 38 | ||||
-rwxr-xr-x | source3/rpc_server/srv_spoolss.c | 50 |
3 files changed, 59 insertions, 31 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 0757d08b8c..9d357204df 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -1304,7 +1304,7 @@ void init_devicemode(NT_DEVICEMODE *nt_devmode) nt_devmode->fields = FORMNAME | TTOPTION | PRINTQUALITY | DEFAULTSOURCE | COPIES | SCALE | PAPERSIZE | ORIENTATION; - nt_devmode->orientation = 2; + nt_devmode->orientation = 1; nt_devmode->papersize = PAPER_A4; nt_devmode->paperlength = 0; nt_devmode->paperwidth = 0; diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index c090239f38..08ea5f73a2 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -462,20 +462,15 @@ void spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_st prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdata"); depth++; + /* grow buffer mem enough */ + mem_grow_data(&(ps->data), ps->io, r_u->size+100, 0); + prs_align(ps); prs_uint32("type", ps, depth, &(r_u->type)); prs_uint32("size", ps, depth, &(r_u->size)); - - switch (r_u->type) - { - case 0x1: - case 0x3: - case 0x4: - case 0x7: - prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size); - prs_align(ps); - break; - } + + prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size); + prs_align(ps); prs_uint32("needed", ps, depth, &(r_u->needed)); prs_uint32("status", ps, depth, &(r_u->status)); @@ -969,6 +964,8 @@ static void smb_io_printer_info_2(char *desc, PRINTER_INFO_2 *info, prs_struct * uint32 *start_offset, uint32 *end_offset) { uint32 pipo=0; + uint32 devmode_offset; + uint32 backup_offset; prs_debug(ps, depth, desc, "smb_io_printer_info_2"); depth++; @@ -982,8 +979,9 @@ static void smb_io_printer_info_2(char *desc, PRINTER_INFO_2 *info, prs_struct * smb_io_relstr("comment", ps, depth, &(info->comment), start_offset, end_offset); smb_io_relstr("location", ps, depth, &(info->location), start_offset, end_offset); - smb_io_reldevmode("devmode", ps, depth, info->devmode, start_offset, end_offset); - + devmode_offset=ps->offset; + ps->offset=ps->offset+4; + smb_io_relstr("sepfile", ps, depth, &(info->sepfile), start_offset, end_offset); smb_io_relstr("printprocessor",ps, depth, &(info->printprocessor), start_offset, end_offset); smb_io_relstr("datatype", ps, depth, &(info->datatype), start_offset, end_offset); @@ -999,6 +997,15 @@ static void smb_io_printer_info_2(char *desc, PRINTER_INFO_2 *info, prs_struct * prs_uint32("status", ps, depth, &(info->status)); prs_uint32("jobs", ps, depth, &(info->cjobs)); prs_uint32("averageppm", ps, depth, &(info->averageppm)); + + /* + I'm not sure if putting the devmode at the end the struct is worth it + but NT does it + */ + backup_offset=ps->offset; + ps->offset=devmode_offset; + smb_io_reldevmode("devmode", ps, depth, info->devmode, start_offset, end_offset); + ps->offset=backup_offset; } /******************************************************************* @@ -1184,7 +1191,8 @@ static uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info) int size=0; size+=4; /* the security descriptor */ - size+=0xDC+4; /* size of the devmode and the ptr */ + size+=info->devmode->size+4; /* size of the devmode and the ptr */ + size+=info->devmode->driverextra; /* if a devmode->private section exists, add its size */ size+=size_of_relative_string( &(info->servername) ); size+=size_of_relative_string( &(info->printername) ); @@ -3307,7 +3315,7 @@ void spoolss_io_q_enumprintprocessors(char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q ********************************************************************/ void spoolss_io_r_enumprinterdata(char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth) { - prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors"); + prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata"); depth++; prs_align(ps); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index c8df41a810..2cb5543f26 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -258,16 +258,17 @@ static BOOL set_printer_hnd_printername(PRINTER_HND *hnd, char *printername) lp_snum_ok(snum) && lp_print_ok(snum) ) { - DEBUGADD(5,("get_printer_snum, share:%s\n",lp_servicename(snum))); + DEBUGADD(5,("share:%s\n",lp_servicename(snum))); marche=get_a_printer(&printer, 2, lp_servicename(snum)); - DEBUGADD(6,("get_printer_snum, marche:%d\n",marche)); + DEBUGADD(6,("marche:%d\n",marche)); if ( marche==0 && ( strlen(printer.info_2->printername) == strlen(back) ) && ( !strncasecmp(printer.info_2->printername, back, strlen(back))) ) { DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); + ZERO_STRUCT(Printer[pnum].dev.printername); strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); free_a_printer(printer, 2); return True; @@ -280,6 +281,7 @@ static BOOL set_printer_hnd_printername(PRINTER_HND *hnd, char *printername) return False; break; case PRINTER_HANDLE_IS_PRINTSERVER: + ZERO_STRUCT(Printer[pnum].dev.printerservername); strncpy(Printer[pnum].dev.printerservername, printername, strlen(printername)); return True; break; @@ -310,12 +312,12 @@ static BOOL get_printer_snum(PRINTER_HND *hnd, int *number) switch (Printer[pnum].printer_type) { case PRINTER_HANDLE_IS_PRINTER: - DEBUG(4,("get_printer_snum, short name:%s\n", Printer[pnum].dev.printername)); + DEBUG(4,("short name:%s\n", Printer[pnum].dev.printername)); for (snum=0;snum<n_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { - DEBUG(4,("get_printer_snum, share:%s\n",lp_servicename(snum))); + DEBUG(4,("share:%s\n",lp_servicename(snum))); if ( ( strlen(lp_servicename(snum)) == strlen( Printer[pnum].dev.printername ) ) && ( !strncasecmp(lp_servicename(snum), Printer[pnum].dev.printername, @@ -522,6 +524,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 size, uint32 *ty return False; } +/******************************************************************** + ********************************************************************/ static BOOL getprinterdata_printer(PRINTER_HND *handle, fstring value, uint32 size, uint32 *type, uint32 *numeric_data, uint8 **data, uint32 *needed ) { @@ -541,21 +545,21 @@ static BOOL getprinterdata_printer(PRINTER_HND *handle, fstring value, uint32 si if (get_specific_param(printer, 2, value, &idata, type, &len)) { - switch (*type) + /*switch (*type) { case 1: case 3: - case 4: + case 4:*/ *data = (uint8 *)malloc( size*sizeof(uint8) ); bzero(*data, sizeof(uint8)*size); memcpy(*data, idata, len>size?size:len); *needed = len; if (idata) free(idata); - break; + /*break;*/ /*case 4: *numeric_data=atoi(idata); break;*/ - } + /*}*/ return (True); } free_a_printer(printer, 2); @@ -626,7 +630,9 @@ static void spoolss_reply_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, prs_struct } spoolss_io_r_getprinterdata("", &r_u, rdata, 0); + DEBUG(3,("freeing memory\n")); if (r_u.data) free(r_u.data); + DEBUG(3,("freeing memory:ok\n")); } } @@ -1723,6 +1729,18 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number, /**************************************************************************** ****************************************************************************/ +static void free_printer_info_2(PRINTER_INFO_2 *printer) +{ + if (printer->devmode->private!=NULL) + free(printer->devmode->private); + if (printer->devmode!=NULL) + free(printer->devmode); + if (printer!=NULL) + free(printer); +} + +/**************************************************************************** +****************************************************************************/ static void free_enum_printers_info_1(PRINTER_INFO_1 **printers, uint32 total) { int number=0; @@ -1750,8 +1768,7 @@ static void free_enum_printers_info_2(PRINTER_INFO_2 **printers, uint32 total) { if (printers[number] != NULL) { - free(printers[number]->devmode); - free(printers[number]); + free_printer_info_2(printers[number]); } } free(printers); @@ -1903,8 +1920,7 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata, r_u.level=q_u->level; spoolss_io_r_getprinter("",&r_u,rdata,0); - free(printer->devmode); - free(printer); + free_printer_info_2(printer); break; } @@ -3265,7 +3281,7 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru uint32 type; fstring value; - uint8 *data; + uint8 *data=NULL; uint32 param_index; uint32 biggest_valuesize; @@ -3292,6 +3308,7 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru r_u.type=0; r_u.datasize=0; r_u.realdatasize=0; + r_u.status=0; param_index=0; biggest_valuesize=0; @@ -3306,7 +3323,10 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru } /* I wrote it, I didn't designed the protocol */ - SIVAL(&(r_u.value),0, 2*(biggest_valuesize+1) ); + if (biggest_valuesize!=0) + { + SIVAL(&(r_u.value),0, 2*(biggest_valuesize+1) ); + } r_u.data=(uint8 *)malloc(4*sizeof(uint8)); SIVAL(r_u.data, 0, biggest_datasize ); } @@ -3347,7 +3367,7 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru free_a_printer(printer, 2); } spoolss_io_r_enumprinterdata("", &r_u, rdata, 0); - free(r_u.data); + if (r_u.data!=NULL) free(r_u.data); } /**************************************************************************** |