diff options
author | Gerald Carter <jerry@samba.org> | 2002-08-30 14:48:33 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2002-08-30 14:48:33 +0000 |
commit | 3cbe8922762817d38b6408154994714ca35f3734 (patch) | |
tree | 70b5d65e8a8709fc68086be0ac54282c291bd771 /source3 | |
parent | dd0d4b527006d4f3724e496ff9d8be3cc1a176b3 (diff) | |
download | samba-3cbe8922762817d38b6408154994714ca35f3734.tar.gz samba-3cbe8922762817d38b6408154994714ca35f3734.tar.bz2 samba-3cbe8922762817d38b6408154994714ca35f3734.zip |
fix up print portion of registry. Merge from APP_HEAD.
(This used to be commit ec37633548ed329c05b93499f75883d987b78f1e)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/printing/nt_printing.c | 4 | ||||
-rw-r--r-- | source3/registry/reg_printing.c | 69 | ||||
-rw-r--r-- | source3/rpc_parse/parse_reg.c | 74 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 2 |
4 files changed, 51 insertions, 98 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index a5b4c5106a..bf90089448 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -2638,8 +2638,8 @@ WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, char *key, char *value, regval_ctr_addvalue( &p2->data.keys[key_index].values, value, type, data, real_len ); - DEBUG(8,("add_printer_data: Added key => [%s], value => [%s], size => [%d]\n", - key, value, real_len )); + DEBUG(8,("add_printer_data: Added key => [%s], value => [%s], type=> [%d], size => [%d]\n", + key, value, type, real_len )); return result; } diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c index 2bc9d056e4..a58a91a0a8 100644 --- a/source3/registry/reg_printing.c +++ b/source3/registry/reg_printing.c @@ -240,6 +240,7 @@ static int print_subpath_values_environments( char *key, REGVAL_CTR *val ) int buffer_size = 0; int i, length; char *filename; + UNISTR2 data;; DEBUG(8,("print_subpath_values_environments: Enter key => [%s]\n", key ? key : "NULL")); @@ -287,15 +288,23 @@ static int print_subpath_values_environments( char *key, REGVAL_CTR *val ) info3 = driver_ctr.info_3; filename = dos_basename( info3->driverpath ); - regval_ctr_addvalue( val, "Driver", REG_SZ, filename, strlen(filename)+1 ); + init_unistr2( &data, filename, strlen(filename)+1 ); + regval_ctr_addvalue( val, "Driver", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + filename = dos_basename( info3->configfile ); - regval_ctr_addvalue( val, "Configuration File", REG_SZ, filename, strlen(filename)+1 ); + init_unistr2( &data, filename, strlen(filename)+1 ); + regval_ctr_addvalue( val, "Configuration File", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + filename = dos_basename( info3->datafile ); - regval_ctr_addvalue( val, "Data File", REG_SZ, filename, strlen(filename)+1 ); + init_unistr2( &data, filename, strlen(filename)+1 ); + regval_ctr_addvalue( val, "Data File", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + filename = dos_basename( info3->helpfile ); - regval_ctr_addvalue( val, "Help File", REG_SZ, filename, strlen(filename)+1 ); - - regval_ctr_addvalue( val, "Data Type", REG_SZ, info3->defaultdatatype, strlen(info3->defaultdatatype)+1 ); + init_unistr2( &data, filename, strlen(filename)+1 ); + regval_ctr_addvalue( val, "Help File", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + + init_unistr2( &data, info3->defaultdatatype, strlen(info3->defaultdatatype)+1 ); + regval_ctr_addvalue( val, "Data Type", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); regval_ctr_addvalue( val, "Version", REG_DWORD, (char*)&info3->cversion, sizeof(info3->cversion) ); @@ -313,19 +322,20 @@ static int print_subpath_values_environments( char *key, REGVAL_CTR *val ) length = strlen(filename); - buffer2 = Realloc( buffer, buffer_size + length + 1 ); + buffer2 = Realloc( buffer, buffer_size + (length + 1)*sizeof(uint16) ); if ( !buffer2 ) break; buffer = buffer2; + + init_unistr2( &data, filename, length+1 ); + memcpy( buffer+buffer_size, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); - memcpy( buffer+buffer_size, filename, length+1 ); - - buffer_size += length + 1; + buffer_size += (length + 1)*sizeof(uint16); } /* terminated by double NULL. Add the final one here */ - buffer2 = Realloc( buffer, buffer_size + 1 ); + buffer2 = Realloc( buffer, buffer_size + 2 ); if ( !buffer2 ) { SAFE_FREE( buffer ); buffer_size = 0; @@ -333,12 +343,14 @@ static int print_subpath_values_environments( char *key, REGVAL_CTR *val ) else { buffer = buffer2; buffer[buffer_size++] = '\0'; + buffer[buffer_size++] = '\0'; } } regval_ctr_addvalue( val, "Dependent Files", REG_MULTI_SZ, buffer, buffer_size ); free_a_printer_driver( driver_ctr, 3 ); + SAFE_FREE( key2 ); SAFE_FREE( buffer ); @@ -522,9 +534,10 @@ static int print_subpath_values_printers( char *key, REGVAL_CTR *val ) fstring printername; NT_PRINTER_DATA *p_data; int i, key_index; + UNISTR2 data; /* - * There are tw cases to deal with here + * Theres are tw cases to deal with here * (1) enumeration of printer_info_2 values * (2) enumeration of the PrinterDriverData subney */ @@ -559,17 +572,27 @@ static int print_subpath_values_printers( char *key, REGVAL_CTR *val ) regval_ctr_addvalue( val, "UntilTime", REG_DWORD, (char*)&info2->untiltime, sizeof(info2->untiltime) ); regval_ctr_addvalue( val, "cjobs", REG_DWORD, (char*)&info2->cjobs, sizeof(info2->cjobs) ); regval_ctr_addvalue( val, "AveragePPM", REG_DWORD, (char*)&info2->averageppm, sizeof(info2->averageppm) ); - - regval_ctr_addvalue( val, "Name", REG_SZ, info2->printername, sizeof(info2->printername)+1 ); - regval_ctr_addvalue( val, "Location", REG_SZ, info2->location, sizeof(info2->location)+1 ); - regval_ctr_addvalue( val, "Comment", REG_SZ, info2->comment, sizeof(info2->comment)+1 ); - regval_ctr_addvalue( val, "Parameters", REG_SZ, info2->parameters, sizeof(info2->parameters)+1 ); - regval_ctr_addvalue( val, "Port", REG_SZ, info2->portname, sizeof(info2->portname)+1 ); - regval_ctr_addvalue( val, "Server", REG_SZ, info2->servername, sizeof(info2->servername)+1 ); - regval_ctr_addvalue( val, "Share", REG_SZ, info2->sharename, sizeof(info2->sharename)+1 ); - regval_ctr_addvalue( val, "Driver", REG_SZ, info2->drivername, sizeof(info2->drivername)+1 ); - regval_ctr_addvalue( val, "Separator File", REG_SZ, info2->sepfile, sizeof(info2->sepfile)+1 ); - regval_ctr_addvalue( val, "Print Processor", REG_SZ, "winprint", sizeof("winprint")+1 ); + + init_unistr2( &data, info2->printername, strlen(info2->printername)+1 ); + regval_ctr_addvalue( val, "Name", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + init_unistr2( &data, info2->location, strlen(info2->location)+1 ); + regval_ctr_addvalue( val, "Location", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + init_unistr2( &data, info2->comment, strlen(info2->comment)+1 ); + regval_ctr_addvalue( val, "Comment", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + init_unistr2( &data, info2->parameters, strlen(info2->parameters)+1 ); + regval_ctr_addvalue( val, "Parameters", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + init_unistr2( &data, info2->portname, strlen(info2->portname)+1 ); + regval_ctr_addvalue( val, "Port", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + init_unistr2( &data, info2->servername, strlen(info2->servername)+1 ); + regval_ctr_addvalue( val, "Server", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + init_unistr2( &data, info2->sharename, strlen(info2->sharename)+1 ); + regval_ctr_addvalue( val, "Share", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + init_unistr2( &data, info2->drivername, strlen(info2->drivername)+1 ); + regval_ctr_addvalue( val, "Driver", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + init_unistr2( &data, info2->sepfile, strlen(info2->sepfile)+1 ); + regval_ctr_addvalue( val, "Separator File", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + init_unistr2( &data, "winprint", strlen("winprint")+1 ); + regval_ctr_addvalue( val, "Print Processor", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); /* use a prs_struct for converting the devmode and security diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c index 1387aaf6ea..f3018cfb37 100644 --- a/source3/rpc_parse/parse_reg.c +++ b/source3/rpc_parse/parse_reg.c @@ -34,83 +34,13 @@ static uint32 reg_init_buffer2( BUFFER2 *buf2, REGISTRY_VALUE *val ) { - UNISTR2 unistr; uint32 real_size = 0; - char *string; - char *list = NULL; - char *list2 = NULL; - int len = 0; if ( !buf2 || !val ) return 0; - real_size = val->size; - - switch (val->type ) - { - case REG_SZ: - string = (char*)regval_data_p( val ); - DEBUG(10,("reg_init_buffer2: REG_SZ string => [%s]\n", string)); - - if ( string ) - len = strlen(string)+1; - - init_unistr2( &unistr, (char*)val->data_p, len ); - init_buffer2( buf2, (char*)unistr.buffer, unistr.uni_str_len*2 ); - real_size = unistr.uni_str_len*2; - break; - - case REG_MULTI_SZ: - string = (char*)val->data_p; - real_size = 0; - while ( string && *string ) - { - DEBUG(10,("reg_init_buffer2: REG_MULTI_SZ string => [%s], size => [%d]\n", string, real_size )); - - init_unistr2( &unistr, string, strlen(string)+1 ); - - list2 = Realloc( list, real_size + unistr.uni_str_len*2 ); - if ( !list2 ) - break; - list = list2; - - memcpy( list+real_size, unistr.buffer, unistr.uni_str_len*2 ); - - real_size += unistr.uni_str_len*2; - - string += strlen(string)+1; - } - - list2 = Realloc( list, real_size + 2 ); - if ( !list2 ) - break; - list = list2; - list[real_size++] = 0x0; - list[real_size++] = 0x0; - - init_buffer2( buf2, (char*)list, real_size ); - - DEBUG(10,("reg_init_buffer2: REG_MULTI_SZ size => [%d]\n", real_size )); - - break; - - case REG_BINARY: - DEBUG(10,("reg_init_buffer2: REG_BINARY size => [%d]\n", val->size )); - - init_buffer2( buf2, val->data_p, val->size ); - break; - - case REG_DWORD: - DEBUG(10,("reg_init_buffer2: REG_DWORD value => [%d]\n", *(uint32*)val->data_p)); - init_buffer2( buf2, val->data_p, val->size ); - break; - - default: - DEBUG(0,("reg_init_buffer2: Unsupported registry data type [%d]\n", val->type)); - break; - } - - SAFE_FREE( list ); + real_size = regval_size(val); + init_buffer2( buf2, (char*)regval_data_p(val), real_size ); return real_size; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d1f92aef13..c4105f9780 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7911,7 +7911,7 @@ done: WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, SPOOL_R_SETPRINTERDATAEX *r_u) { - POLICY_HND *handle = &q_u->handle; + POLICY_HND *handle = &q_u->handle; uint32 type = q_u->type; uint8 *data = q_u->data; uint32 real_len = q_u->real_len; |