summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/registry/reg_backend_printing.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/source3/registry/reg_backend_printing.c b/source3/registry/reg_backend_printing.c
index cc44f877bb..453e2b2d0c 100644
--- a/source3/registry/reg_backend_printing.c
+++ b/source3/registry/reg_backend_printing.c
@@ -575,7 +575,16 @@ static int find_valuename_index( const char *valuename )
/**********************************************************************
*********************************************************************/
-static void convert_values_to_printer_info_2(NT_PRINTER_INFO_LEVEL_2 *printer2, struct regval_ctr *values)
+static void pull_reg_sz_fstring(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, fstring s)
+{
+ const char *str;
+ pull_reg_sz(mem_ctx, blob, &str);
+ fstrcpy(s, str);
+}
+
+static void convert_values_to_printer_info_2(TALLOC_CTX *mem_ctx,
+ NT_PRINTER_INFO_LEVEL_2 *printer2,
+ struct regval_ctr *values)
{
int num_values = regval_ctr_numvals( values );
uint32 value_index;
@@ -583,8 +592,11 @@ static void convert_values_to_printer_info_2(NT_PRINTER_INFO_LEVEL_2 *printer2,
int i;
for ( i=0; i<num_values; i++ ) {
+ DATA_BLOB blob;
val = regval_ctr_specific_value( values, i );
value_index = find_valuename_index( regval_name( val ) );
+
+ blob = data_blob_const(regval_data_p(val), regval_size(val));
switch( value_index ) {
case REG_IDX_ATTRIBUTES:
@@ -606,34 +618,34 @@ static void convert_values_to_printer_info_2(NT_PRINTER_INFO_LEVEL_2 *printer2,
printer2->untiltime = (uint32)(*regval_data_p(val));
break;
case REG_IDX_NAME:
- rpcstr_pull( printer2->printername, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->printername);
break;
case REG_IDX_LOCATION:
- rpcstr_pull( printer2->location, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->location);
break;
case REG_IDX_DESCRIPTION:
- rpcstr_pull( printer2->comment, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->comment);
break;
case REG_IDX_PARAMETERS:
- rpcstr_pull( printer2->parameters, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->parameters);
break;
case REG_IDX_PORT:
- rpcstr_pull( printer2->portname, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->portname);
break;
case REG_IDX_SHARENAME:
- rpcstr_pull( printer2->sharename, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->sharename);
break;
case REG_IDX_DRIVER:
- rpcstr_pull( printer2->drivername, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->drivername);
break;
case REG_IDX_SEP_FILE:
- rpcstr_pull( printer2->sepfile, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->sepfile);
break;
case REG_IDX_PRINTPROC:
- rpcstr_pull( printer2->printprocessor, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->printprocessor);
break;
case REG_IDX_DATATYPE:
- rpcstr_pull( printer2->datatype, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
+ pull_reg_sz_fstring(mem_ctx, &blob, printer2->datatype);
break;
case REG_IDX_DEVMODE:
break;
@@ -658,6 +670,7 @@ static bool key_printers_store_values(const char *key, struct regval_ctr *values
char *printername, *keyname;
NT_PRINTER_INFO_LEVEL *printer = NULL;
WERROR result;
+ TALLOC_CTX *mem_ctx = talloc_init("key_printers_store_values");
printers_key = strip_printers_prefix( key );
@@ -678,7 +691,7 @@ static bool key_printers_store_values(const char *key, struct regval_ctr *values
/* deal with setting values directly under the printername */
if ( !keyname ) {
- convert_values_to_printer_info_2( printer->info_2, values );
+ convert_values_to_printer_info_2(mem_ctx, printer->info_2, values );
}
else {
int num_values = regval_ctr_numvals( values );
@@ -699,6 +712,7 @@ static bool key_printers_store_values(const char *key, struct regval_ctr *values
DEBUG(0,("key_printers_store_values: failed to set printer data [%s]!\n",
keyname));
free_a_printer( &printer, 2 );
+ talloc_destroy(mem_ctx);
return False;
}
}
@@ -707,6 +721,7 @@ static bool key_printers_store_values(const char *key, struct regval_ctr *values
result = mod_a_printer( printer, 2 );
free_a_printer( &printer, 2 );
+ talloc_destroy(mem_ctx);
return W_ERROR_IS_OK(result);
}