summaryrefslogtreecommitdiff
path: root/source3/rpc_parse/parse_spoolss.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_parse/parse_spoolss.c')
-rw-r--r--source3/rpc_parse/parse_spoolss.c103
1 files changed, 96 insertions, 7 deletions
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index b8762b35e2..db3ea5046a 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -1212,6 +1212,26 @@ BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
}
/*******************************************************************
+ * make a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX *q_u,
+ const POLICY_HND *handle,
+ char *keyname, char *valuename, uint32 size)
+{
+ if (q_u == NULL) return False;
+
+ DEBUG(5,("make_spoolss_q_getprinterdataex\n"));
+
+ q_u->handle = *handle;
+ init_unistr2(&q_u->valuename, valuename, strlen(valuename) + 1);
+ init_unistr2(&q_u->keyname, keyname, strlen(keyname) + 1);
+ q_u->size = size;
+
+ return True;
+}
+
+/*******************************************************************
* read a structure.
* called from spoolss_q_getprinterdata (srv_spoolss.c)
********************************************************************/
@@ -1344,7 +1364,7 @@ BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_st
if (UNMARSHALLING(ps) && r_u->size) {
r_u->data = prs_alloc_mem(ps, r_u->size);
- if(r_u->data)
+ if(!r_u->data)
return False;
}
@@ -6067,11 +6087,25 @@ BOOL make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
/*******************************************************************
********************************************************************/
+
+BOOL make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
+ const POLICY_HND *hnd, char *key,
+ uint32 size)
+{
+ memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
+ init_unistr2(&q_u->key, key, strlen(key)+1);
+ q_u->size = size;
+
+ return True;
+}
+
+/*******************************************************************
+********************************************************************/
BOOL make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND *hnd,
- char* value, char* data, uint32 data_size)
+ char* value, uint32 data_type, char* data, uint32 data_size)
{
memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
- q_u->type = REG_SZ;
+ q_u->type = data_type;
init_unistr2(&q_u->value, value, strlen(value)+1);
q_u->max_len = q_u->real_len = data_size;
@@ -6079,6 +6113,24 @@ BOOL make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND
return True;
}
+
+/*******************************************************************
+********************************************************************/
+BOOL make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX *q_u, const POLICY_HND *hnd,
+ char *key, char* value, uint32 data_type, char* data,
+ uint32 data_size)
+{
+ memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
+ q_u->type = data_type;
+ init_unistr2(&q_u->value, value, strlen(value)+1);
+ init_unistr2(&q_u->key, key, strlen(key)+1);
+
+ q_u->max_len = q_u->real_len = data_size;
+ q_u->data = data;
+
+ return True;
+}
+
/*******************************************************************
********************************************************************/
@@ -6863,6 +6915,12 @@ BOOL spoolss_io_r_getprinterdataex(char *desc, SPOOL_R_GETPRINTERDATAEX *r_u, pr
if (!prs_uint32("size", ps, depth, &r_u->size))
return False;
+ if (UNMARSHALLING(ps) && r_u->size) {
+ r_u->data = prs_alloc_mem(ps, r_u->size);
+ if(!r_u->data)
+ return False;
+ }
+
if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size))
return False;
@@ -7083,9 +7141,6 @@ static BOOL spoolss_io_printer_enum_values_ctr(char *desc, prs_struct *ps,
prs_debug(ps, depth, desc, "spoolss_io_printer_enum_values_ctr");
depth++;
- if (!prs_uint32("size", ps, depth, &ctr->size))
- return False;
-
/*
* offset data begins at 20 bytes per structure * size_of_array.
* Don't forget the uint32 at the beginning
@@ -7095,6 +7150,13 @@ static BOOL spoolss_io_printer_enum_values_ctr(char *desc, prs_struct *ps,
/* first loop to write basic enum_value information */
+ if (UNMARSHALLING(ps)) {
+ ctr->values = (PRINTER_ENUM_VALUES *)prs_alloc_mem(
+ ps, ctr->size_of_array * sizeof(PRINTER_ENUM_VALUES));
+ if (!ctr->values)
+ return False;
+ }
+
for (i=0; i<ctr->size_of_array; i++)
{
valuename_offset = current_offset;
@@ -7131,6 +7193,13 @@ static BOOL spoolss_io_printer_enum_values_ctr(char *desc, prs_struct *ps,
if (!prs_unistr("valuename", ps, depth, &ctr->values[i].valuename))
return False;
+ if (UNMARSHALLING(ps)) {
+ ctr->values[i].data = (uint8 *)prs_alloc_mem(
+ ps, ctr->values[i].data_len);
+ if (!ctr->values[i].data)
+ return False;
+ }
+
if (!prs_uint8s(False, "data", ps, depth, ctr->values[i].data, ctr->values[i].data_len))
return False;
@@ -7148,15 +7217,21 @@ static BOOL spoolss_io_printer_enum_values_ctr(char *desc, prs_struct *ps,
BOOL spoolss_io_r_enumprinterdataex(char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth)
{
+ int data_offset, end_offset;
prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdataex");
depth++;
if(!prs_align(ps))
return False;
- if (!spoolss_io_printer_enum_values_ctr("", ps, &r_u->ctr, depth ))
+ if (!prs_uint32("size", ps, depth, &r_u->ctr.size))
return False;
+ data_offset = prs_offset(ps);
+
+ if (!prs_set_offset(ps, data_offset + r_u->ctr.size))
+ return False;
+
if(!prs_align(ps))
return False;
@@ -7169,6 +7244,20 @@ BOOL spoolss_io_r_enumprinterdataex(char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u,
if(!prs_werror("status", ps, depth, &r_u->status))
return False;
+ r_u->ctr.size_of_array = r_u->returned;
+
+ end_offset = prs_offset(ps);
+
+ if (!prs_set_offset(ps, data_offset))
+ return False;
+
+ if (r_u->ctr.size)
+ if (!spoolss_io_printer_enum_values_ctr("", ps, &r_u->ctr, depth ))
+ return False;
+
+ if (!prs_set_offset(ps, end_offset))
+ return False;
+
return True;
}