diff options
author | Tim Potter <tpot@samba.org> | 2002-03-26 05:20:51 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-03-26 05:20:51 +0000 |
commit | b958e865cadfa5a337d5d503d6c7dd324e84ef64 (patch) | |
tree | eddc41cb570dce51b975c8670767d35e7efb277c | |
parent | 78fd37d27c2d5184f08a353377b007b10d87f180 (diff) |
Use dcerpc_call_value structure to fetch request/response frame numbers
and storage of private data.
Fix memory leaks in form dissectors.
svn path=/trunk/; revision=5020
-rw-r--r-- | packet-dcerpc-nt.c | 268 | ||||
-rw-r--r-- | packet-dcerpc-nt.h | 30 | ||||
-rw-r--r-- | packet-dcerpc-spoolss.c | 552 |
3 files changed, 233 insertions, 617 deletions
diff --git a/packet-dcerpc-nt.c b/packet-dcerpc-nt.c index 3a7741b5fd..81550b087f 100644 --- a/packet-dcerpc-nt.c +++ b/packet-dcerpc-nt.c @@ -2,7 +2,7 @@ * Routines for DCERPC over SMB packet disassembly * Copyright 2001, Tim Potter <tpot@samba.org> * - * $Id: packet-dcerpc-nt.c,v 1.22 2002/03/25 05:42:02 tpot Exp $ + * $Id: packet-dcerpc-nt.c,v 1.23 2002/03/26 05:20:51 tpot Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -655,271 +655,6 @@ dissect_ndr_nt_NTTIME (tvbuff_t *tvb, int offset, #undef DEBUG_HASH_COLL /* - * DCERPC/SMB request/response matching routines. As usual, we keep a hash - * table to match up requests and responses and also store data that needs - * to be passed between the request dissector and the response dissector. - * This table is keyed by the tuple (conversation index, smb_fid, opnum). - */ - -typedef struct { - int conv; /* Which conversation we are in */ - guint16 smb_fid; /* File descriptor */ - guint16 opnum; /* Operation number */ - guint32 call_id; /* Call id */ -} rr_hash_key; - -typedef struct { - int request_frame, response_frame; /* Frame numbers */ - void *data; /* Private data */ - int len; /* Length of private data */ -} rr_hash_value; - -#define RR_HASH_INIT_COUNT 100 - -static GHashTable *rr_hash; -static GMemChunk *rr_hash_key_chunk; -static GMemChunk *rr_hash_value_chunk; - -/* Hash function */ - -static guint rr_hash_fn(gconstpointer k) -{ - rr_hash_key *key = (rr_hash_key *)k; - - /* Hash sum of key contents */ - - return key->conv + key->smb_fid + key->opnum + key->call_id; -} - -/* Hash compare function */ - -static gint rr_hash_compare(gconstpointer k1, gconstpointer k2) -{ - rr_hash_key *key1 = (rr_hash_key *)k1; - rr_hash_key *key2 = (rr_hash_key *)k2; - - return (key1->conv == key2->conv) && - (key1->smb_fid == key2->smb_fid) && - (key1->opnum == key2->opnum) && - (key1->call_id == key2->call_id); -} - -/* Iterator to free a request/response key/value pair */ - -static void free_rr_keyvalue(gpointer key, gpointer value, gpointer user_data) -{ - rr_hash_value *rr_value = (rr_hash_value *)value; - - /* Free user data */ - - if (rr_value->data) { - free(rr_value->data); - rr_value->data = NULL; - } -} - -/* Initialise request/response hash table */ - -static void init_rr_hash(void) -{ - /* Initialise memory chunks */ - - if (rr_hash_key_chunk) - g_mem_chunk_destroy(rr_hash_key_chunk); - - rr_hash_key_chunk = g_mem_chunk_new( - "DCERPC/SMB request/response keys", sizeof(rr_hash_key), - RR_HASH_INIT_COUNT * sizeof(rr_hash_key), G_ALLOC_ONLY); - - if (rr_hash_value_chunk) - g_mem_chunk_destroy(rr_hash_value_chunk); - - rr_hash_value_chunk = g_mem_chunk_new( - "DCERPC/SMB request/response values", sizeof(rr_hash_value), - RR_HASH_INIT_COUNT * sizeof(rr_hash_value), G_ALLOC_ONLY); - - /* Initialise hash table */ - - if (rr_hash) { - g_hash_table_foreach(rr_hash, free_rr_keyvalue, NULL); - g_hash_table_destroy(rr_hash); - } - - rr_hash = g_hash_table_new(rr_hash_fn, rr_hash_compare); -} - -static void rr_hash_makekey(dcerpc_info *di, guint16 opnum, rr_hash_key *key) -{ - key->conv = di->conv->index; - key->smb_fid = di->smb_fid; - key->opnum = opnum; - key->call_id = di->call_id; -} - -/* Add a dcerpc/smb request to the request/response hash table */ - -void dcerpc_smb_store_q(dcerpc_info *di, guint16 opnum, int frame_num) -{ - rr_hash_key *key; - rr_hash_value *value; - - /* Create key */ - - key = g_mem_chunk_alloc(rr_hash_key_chunk); - - rr_hash_makekey(di, opnum, key); - - /* Have we already seen this packet? */ - - if ((value = g_hash_table_lookup(rr_hash, key))) { - - if (!value->request_frame) - value->request_frame = frame_num; - else { -#ifdef DEBUG_HASH_COLL - if (value->request_frame != frame_num) - g_warning( "dcerpc_smb: rr_hash request collision with frames %d/%d\n", value->request_frame, frame_num); -#endif - } - - g_mem_chunk_free(rr_hash_key_chunk, key); - - return; - } - - /* Create new value */ - - value = g_mem_chunk_alloc(rr_hash_value_chunk); - - value->request_frame = frame_num; - value->response_frame = 0; - value->data = NULL; - - g_hash_table_insert(rr_hash, key, value); -} - -/* Add a dcerpc/smb response to the request/response hash table */ - -void dcerpc_smb_store_r(dcerpc_info *di, guint16 opnum, int frame_num) -{ - rr_hash_key *key; - rr_hash_value *value; - - /* Create key */ - - key = g_mem_chunk_alloc(rr_hash_key_chunk); - - rr_hash_makekey(di, opnum, key); - - /* Have we already seen this packet? */ - - if ((value = g_hash_table_lookup(rr_hash, key))) { - - if (!value->response_frame) - value->response_frame = frame_num; - else { -#ifdef DEBUG_HASH_COLL - if (value->response_frame != frame_num) - g_warning("dcerpc_smb: rr_hash response collision with frames %d/%d\n", value->response_frame, frame_num); -#endif - } - - g_mem_chunk_free(rr_hash_key_chunk, key); - - return; - } - - /* Create new value */ - - value = g_mem_chunk_alloc(rr_hash_value_chunk); - - value->request_frame = 0; - value->response_frame = frame_num; - value->data = NULL; - - g_hash_table_insert(rr_hash, key, value); -} - -/* Store private data to a request/response entry */ - -void dcerpc_smb_store_priv(dcerpc_info *di, guint16 opnum, void *data, - int len) -{ - rr_hash_key key; - rr_hash_value *value; - - rr_hash_makekey(di, opnum, &key); - - if (!(value = g_hash_table_lookup(rr_hash, &key))) { - g_warning("dcerpc_smb: no such request/response 0x%x, op %d\n", - key.smb_fid, key.opnum); - return; - } - - if (value->data) - free(value->data); - - value->data = malloc(len); - value->len = len; - - memcpy(value->data, data, len); -} - -/* Fetch private data from a request/response entry */ - -void *dcerpc_smb_fetch_priv(dcerpc_info *di, guint16 opnum, int *len) -{ - rr_hash_key key; - rr_hash_value *value; - - rr_hash_makekey(di, opnum, &key); - - value = g_hash_table_lookup(rr_hash, &key); - - if (value && value->data) { - if (len) - *len = value->len; - return value->data; - } - - return NULL; -} - -/* Return the request number for a DCERPC/SMB request/response pair */ - -guint32 dcerpc_smb_fetch_q(dcerpc_info *di, guint16 opnum) -{ - rr_hash_key key; - rr_hash_value *value; - - rr_hash_makekey(di, opnum, &key); - - value = g_hash_table_lookup(rr_hash, &key); - - if (value) - return value->request_frame; - - return 0; -} - -/* Return the request number for a DCERPC/SMB request/response pair */ - -guint32 dcerpc_smb_fetch_r(dcerpc_info *di, guint16 opnum) -{ - rr_hash_key key; - rr_hash_value *value; - - rr_hash_makekey(di, opnum, &key); - - value = g_hash_table_lookup(rr_hash, &key); - - if (value) - return value->response_frame; - - return 0; -} - -/* * Policy handle hashing */ @@ -1129,7 +864,6 @@ void dcerpc_smb_init(void) if (done_init) return; - init_rr_hash(); init_pol_hash(); done_init = TRUE; diff --git a/packet-dcerpc-nt.h b/packet-dcerpc-nt.h index 78ede999ca..240ef613b2 100644 --- a/packet-dcerpc-nt.h +++ b/packet-dcerpc-nt.h @@ -2,7 +2,7 @@ * Routines for DCERPC over SMB packet disassembly * Copyright 2001, Tim Potter <tpot@samba.org> * - * $Id: packet-dcerpc-nt.h,v 1.15 2002/03/25 05:42:01 tpot Exp $ + * $Id: packet-dcerpc-nt.h,v 1.16 2002/03/26 05:20:51 tpot Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -127,31 +127,6 @@ dissect_ndr_nt_SID_AND_ATTRIBUTES(tvbuff_t *tvb, int offset, char *drep); /* - * Request/response matching functions. We also hang private data here. - */ - -void -dcerpc_smb_init(void); - -guint32 -dcerpc_smb_fetch_q(dcerpc_info *di, guint16 opnum); - -void -dcerpc_smb_store_q(dcerpc_info *di, guint16 opnum, int frame_num); - -guint32 -dcerpc_smb_fetch_r(dcerpc_info *di, guint16 opnum); - -void -dcerpc_smb_store_r(dcerpc_info *di, guint16 opnum, int frame_num); - -void -dcerpc_smb_store_priv(dcerpc_info *di, guint16 opnum, void *data, int len); - -void * -dcerpc_smb_fetch_priv(dcerpc_info *di, guint16 opnum, int *len); - -/* * Policy handle hashing */ @@ -168,4 +143,7 @@ void dcerpc_smb_check_long_frame(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree); +void +dcerpc_smb_init(void); + #endif /* packet-dcerpc-nt.h */ diff --git a/packet-dcerpc-spoolss.c b/packet-dcerpc-spoolss.c index 4d2e9f280a..a3534c341f 100644 --- a/packet-dcerpc-spoolss.c +++ b/packet-dcerpc-spoolss.c @@ -2,7 +2,7 @@ * Routines for SMB \PIPE\spoolss packet disassembly * Copyright 2001, Tim Potter <tpot@samba.org> * - * $Id: packet-dcerpc-spoolss.c,v 1.10 2002/03/26 04:29:17 tpot Exp $ + * $Id: packet-dcerpc-spoolss.c,v 1.11 2002/03/26 05:20:50 tpot Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -241,7 +241,7 @@ static int SpoolssClosePrinter_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; const guint8 *policy_hnd; /* Update informational fields */ @@ -249,12 +249,9 @@ static int SpoolssClosePrinter_q(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "ClosePrinter request"); - dcerpc_smb_store_q(di, SPOOLSS_CLOSEPRINTER, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_CLOSEPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); - + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ offset = prs_policy_hnd(tvb, offset, pinfo, NULL, &policy_hnd); @@ -273,7 +270,7 @@ static int SpoolssClosePrinter_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; const guint8 *policy_hnd; /* Update informational fields */ @@ -281,11 +278,9 @@ static int SpoolssClosePrinter_r(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "ClosePrinter response"); - dcerpc_smb_store_r(di, SPOOLSS_CLOSEPRINTER, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_CLOSEPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -361,7 +356,7 @@ static int SpoolssGetPrinterData_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; char *value_name = NULL; const guint8 *policy_hnd; @@ -370,9 +365,9 @@ static int SpoolssGetPrinterData_q(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "GetPrinterData request"); - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_GETPRINTERDATA))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -401,7 +396,7 @@ static int SpoolssGetPrinterData_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; guint32 size, type; @@ -410,11 +405,9 @@ static int SpoolssGetPrinterData_r(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "GetPrinterData response"); - dcerpc_smb_store_r(di, SPOOLSS_GETPRINTERDATA, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_GETPRINTERDATA))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -445,21 +438,18 @@ static int SpoolssGetPrinterDataEx_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; char *key_name, *value_name; const guint8 *policy_hnd; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "GetPrinterDataEx request"); + col_set_str(pinfo->cinfo, COL_INFO, "GetPrinterDataEx request"); - dcerpc_smb_store_q(di, SPOOLSS_GETPRINTERDATAEX, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_q(di, SPOOLSS_GETPRINTERDATAEX))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -508,20 +498,18 @@ static int SpoolssGetPrinterDataEx_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; guint32 size, type; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "GetPrinterDataEx response"); + col_set_str(pinfo->cinfo, COL_INFO, "GetPrinterDataEx response"); - dcerpc_smb_store_r(di, SPOOLSS_GETPRINTERDATAEX, pinfo->fd->num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_GETPRINTERDATAEX))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); /* Parse packet */ offset = prs_uint32(tvb, offset, pinfo, tree, &type, NULL); @@ -551,7 +539,7 @@ static int SpoolssSetPrinterData_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; char *value_name = NULL; guint32 type, max_len; const guint8 *policy_hnd; @@ -561,11 +549,10 @@ static int SpoolssSetPrinterData_q(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "SetPrinterData request"); - dcerpc_smb_store_q(di, SPOOLSS_SETPRINTERDATA, pinfo->fd->num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_SETPRINTERDATA))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); /* Parse packet */ offset = prs_policy_hnd(tvb, offset, pinfo, NULL, &policy_hnd); @@ -603,7 +590,7 @@ static int SpoolssSetPrinterData_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; /* Update informational fields */ @@ -611,11 +598,9 @@ static int SpoolssSetPrinterData_r(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "SetPrinterData response"); - dcerpc_smb_store_r(di, SPOOLSS_SETPRINTERDATA, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_SETPRINTERDATA))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -635,7 +620,7 @@ static int SpoolssSetPrinterDataEx_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; char *key_name, *value_name; guint32 type, max_len; @@ -644,14 +629,11 @@ static int SpoolssSetPrinterDataEx_q(tvbuff_t *tvb, int offset, /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "SetPrinterDataEx request"); - - dcerpc_smb_store_q(di, SPOOLSS_SETPRINTERDATAEX, pinfo->fd->num); + col_set_str(pinfo->cinfo, COL_INFO, "SetPrinterDataEx request"); - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_SETPRINTERDATAEX))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -696,20 +678,17 @@ static int SpoolssSetPrinterDataEx_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "SetPrinterDataEx response"); - - dcerpc_smb_store_r(di, SPOOLSS_SETPRINTERDATAEX, pinfo->fd->num); + col_set_str(pinfo->cinfo, COL_INFO, "SetPrinterDataEx response"); - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_SETPRINTERDATAEX))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -1146,7 +1125,7 @@ static int SpoolssOpenPrinterEx_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; char *printer_name; guint32 ptr = 0; @@ -1155,11 +1134,10 @@ static int SpoolssOpenPrinterEx_q(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "OpenPrinterEx request"); - dcerpc_smb_store_q(di, SPOOLSS_OPENPRINTEREX, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_OPENPRINTEREX))) + if (dcv->rep_frame != -1) proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + "Response in frame %d", dcv->rep_frame); + /* Parse packet */ offset = prs_ptr(tvb, offset, pinfo, tree, &ptr, "Printer name"); @@ -1178,10 +1156,7 @@ static int SpoolssOpenPrinterEx_q(tvbuff_t *tvb, int offset, /* Store printer name to match with response packet */ - dcerpc_smb_store_priv(di, SPOOLSS_OPENPRINTEREX, - printer_name, strlen(printer_name) + 1); - - g_free(printer_name); + dcv->private_data = printer_name; } offset = prs_struct_and_referents(tvb, offset, pinfo, tree, @@ -1202,7 +1177,7 @@ static int SpoolssOpenPrinterEx_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; guint32 status; const guint8 *policy_hnd; @@ -1212,11 +1187,9 @@ static int SpoolssOpenPrinterEx_r(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "OpenPrinterEx response"); - dcerpc_smb_store_r(di, SPOOLSS_OPENPRINTEREX, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_OPENPRINTEREX))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -1227,16 +1200,16 @@ static int SpoolssOpenPrinterEx_r(tvbuff_t *tvb, int offset, offset = prs_werror(tvb, offset, pinfo, tree, &status); if (status == 0) { - char *printer_name; /* Associate the returned printer handle with a name */ - printer_name = dcerpc_smb_fetch_priv( - di, SPOOLSS_OPENPRINTEREX, NULL); - - if (printer_name) - dcerpc_smb_store_pol(policy_hnd, printer_name, + if (dcv->private_data) { + dcerpc_smb_store_pol(policy_hnd, dcv->private_data, pinfo->fd->num, 0); + + g_free(dcv->private_data); + dcv->private_data = NULL; + } } dcerpc_smb_check_long_frame(tvb, offset, pinfo, tree); @@ -1381,7 +1354,7 @@ static int SpoolssRFFPCNEX_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; char *printer_name; guint32 ptr = 0; const guint8 *policy_hnd; @@ -1391,11 +1364,9 @@ static int SpoolssRFFPCNEX_q(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "RFFPCNEX request"); - dcerpc_smb_store_q(di, SPOOLSS_RFFPCNEX, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_RFFPCNEX))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -1417,6 +1388,7 @@ static int SpoolssRFFPCNEX_q(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", printer_name); + g_free(printer_name); } @@ -1440,18 +1412,16 @@ static int SpoolssRFFPCNEX_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "RFFPCNEX response"); - dcerpc_smb_store_r(di, SPOOLSS_RFFPCNEX, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_RFFPCNEX))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -1471,20 +1441,17 @@ static int SpoolssReplyOpenPrinter_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; guint32 ptr = 0, type; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "ReplyOpenPrinter request"); + col_set_str(pinfo->cinfo, COL_INFO, "ReplyOpenPrinter request"); - dcerpc_smb_store_q(di, SPOOLSS_REPLYOPENPRINTER, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_REPLYOPENPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -1512,21 +1479,19 @@ static int SpoolssReplyOpenPrinter_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; const guint8 *policy_hnd; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "ReplyOpenPrinter response"); + col_set_str(pinfo->cinfo, COL_INFO, "ReplyOpenPrinter response"); - dcerpc_smb_store_r(di, SPOOLSS_REPLYOPENPRINTER, pinfo->fd->num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_REPLYOPENPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); /* Parse packet */ offset = prs_policy_hnd(tvb, offset, pinfo, NULL, &policy_hnd); @@ -1627,7 +1592,7 @@ static int SpoolssGetPrinter_q(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; guint32 level; const guint8 *policy_hnd; @@ -1637,11 +1602,10 @@ static int SpoolssGetPrinter_q(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "GetPrinter request"); - dcerpc_smb_store_q(di, SPOOLSS_GETPRINTER, pinfo->fd->num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_GETPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); /* Parse packet */ offset = prs_policy_hnd(tvb, offset, pinfo, NULL, &policy_hnd); @@ -1656,7 +1620,7 @@ static int SpoolssGetPrinter_q(tvbuff_t *tvb, int offset, packet_info *pinfo, offset = prs_struct_and_referents(tvb, offset, pinfo, tree, prs_BUFFER, NULL, NULL); - dcerpc_smb_store_priv(di, SPOOLSS_GETPRINTER, &level, sizeof(level)); + dcv->private_data = (void *)level; offset = prs_uint32(tvb, offset, pinfo, tree, NULL, "Offered"); @@ -1669,7 +1633,7 @@ static int SpoolssGetPrinter_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; void **data_list; struct BUFFER_DATA *bd = NULL; @@ -1679,11 +1643,9 @@ static int SpoolssGetPrinter_r(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "GetPrinter response"); - dcerpc_smb_store_r(di, SPOOLSS_GETPRINTER, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_GETPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -1694,15 +1656,11 @@ static int SpoolssGetPrinter_r(tvbuff_t *tvb, int offset, packet_info *pinfo, bd = (struct BUFFER_DATA *)data_list[0]; if (bd && bd->tree) { - gint16 *level; + gint16 level = (guint32)dcv->private_data; - if (!(level = dcerpc_smb_fetch_priv( - di, SPOOLSS_GETPRINTER, NULL))) - goto done; + proto_item_append_text(bd->item, ", PRINTER_INFO_%d", level); - proto_item_append_text(bd->item, ", PRINTER_INFO_%d", *level); - - switch (*level) { + switch (level) { case 0: prs_PRINTER_INFO_0(bd->tvb, bd->offset, pinfo, bd->tree, &dp_list, NULL); @@ -1715,8 +1673,7 @@ static int SpoolssGetPrinter_r(tvbuff_t *tvb, int offset, packet_info *pinfo, default: proto_tree_add_text(tree, tvb, offset, 0, - "[Unimplemented info level %d]", - *level); + "[Unimplemented info level %d]", level); break; } } @@ -1768,7 +1725,7 @@ static int SpoolssSetPrinter_q(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; guint32 level; const guint8 *policy_hnd; @@ -1778,11 +1735,9 @@ static int SpoolssSetPrinter_q(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "SetPrinter request"); - dcerpc_smb_store_q(di, SPOOLSS_SETPRINTER, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_SETPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -1815,7 +1770,7 @@ static int SpoolssSetPrinter_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; /* Update informational fields */ @@ -1823,11 +1778,9 @@ static int SpoolssSetPrinter_r(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "SetPrinter response"); - dcerpc_smb_store_r(di, SPOOLSS_SETPRINTER, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_SETPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -1887,7 +1840,7 @@ static int SpoolssEnumForms_q(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; GList *dp_list = NULL; guint32 level; const guint8 *policy_hnd; @@ -1897,11 +1850,9 @@ static int SpoolssEnumForms_q(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "EnumForms request"); - dcerpc_smb_store_q(di, SPOOLSS_ENUMFORMS, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_ENUMFORMS))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -1911,7 +1862,7 @@ static int SpoolssEnumForms_q(tvbuff_t *tvb, int offset, packet_info *pinfo, offset = prs_uint32(tvb, offset, pinfo, tree, &level, "Level"); - dcerpc_smb_store_priv(di, SPOOLSS_ENUMFORMS, &level, sizeof(level)); + dcv->private_data = (void *)level; if (check_col(pinfo->cinfo, COL_INFO)) col_append_fstr(pinfo->cinfo, COL_INFO, ", level %d", level); @@ -1930,7 +1881,8 @@ static int SpoolssEnumForms_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num, count; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; + guint32 count; GList *dp_list = NULL; struct BUFFER_DATA *bd = NULL; void **data_list; @@ -1940,11 +1892,9 @@ static int SpoolssEnumForms_r(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "EnumForms response"); - dcerpc_smb_store_r(di, SPOOLSS_ENUMFORMS, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_ENUMFORMS))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -1961,19 +1911,13 @@ static int SpoolssEnumForms_r(tvbuff_t *tvb, int offset, packet_info *pinfo, CLEANUP_PUSH(g_free, bd); if (bd && bd->tree) { - guint32 *level, i; + guint32 level = (guint32)dcv->private_data, i; GList *child_dp_list = NULL; - level = dcerpc_smb_fetch_priv(di, SPOOLSS_ENUMFORMS, NULL); - - if (!level) - goto done; - if (check_col(pinfo->cinfo, COL_INFO)) - col_append_fstr(pinfo->cinfo, COL_INFO, ", level %d", - *level); + col_append_fstr(pinfo->cinfo, COL_INFO, ", level %d", level); - proto_item_append_text(bd->item, ", FORM_%d", *level); + proto_item_append_text(bd->item, ", FORM_%d", level); /* Unfortunately this array isn't in NDR format so we can't use prs_array(). The other weird thing is the @@ -2009,7 +1953,7 @@ static int SpoolssDeletePrinter_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; const guint8 *policy_hnd; /* Update informational fields */ @@ -2017,11 +1961,9 @@ static int SpoolssDeletePrinter_q(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "DeletePrinter request"); - dcerpc_smb_store_q(di, SPOOLSS_DELETEPRINTER, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_DELETEPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -2039,7 +1981,7 @@ static int SpoolssDeletePrinter_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; const guint8 *policy_hnd; /* Update informational fields */ @@ -2047,11 +1989,9 @@ static int SpoolssDeletePrinter_r(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "DeletePrinter response"); - dcerpc_smb_store_r(di, SPOOLSS_DELETEPRINTER, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_DELETEPRINTER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -2075,36 +2015,31 @@ static int SpoolssAddPrinterEx_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; guint32 ptr; - char *printer_name; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "AddPrinterEx request"); - dcerpc_smb_store_q(di, SPOOLSS_ADDPRINTEREX, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_ADDPRINTEREX))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); - + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); + /* Parse packet */ offset = prs_ptr(tvb, offset, pinfo, tree, &ptr, "Server name"); if (ptr) { + char *printer_name; + offset = prs_struct_and_referents(tvb, offset, pinfo, tree, prs_UNISTR2_dp, (void *)&printer_name, NULL); if (printer_name) - dcerpc_smb_store_priv( - di, SPOOLSS_ADDPRINTEREX, printer_name, - strlen(printer_name) + 1); - - g_free(printer_name); + dcv->private_data = printer_name; } offset = prs_uint32(tvb, offset, pinfo, tree, NULL, "Level"); @@ -2129,7 +2064,7 @@ static int SpoolssAddPrinterEx_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; guint32 status; const guint8 *policy_hnd; @@ -2138,11 +2073,9 @@ static int SpoolssAddPrinterEx_r(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "AddPrinterEx response"); - dcerpc_smb_store_r(di, SPOOLSS_ADDPRINTEREX, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_ADDPRINTEREX))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -2153,25 +2086,22 @@ static int SpoolssAddPrinterEx_r(tvbuff_t *tvb, int offset, packet_info *pinfo, offset = prs_werror(tvb, offset, pinfo, tree, &status); if (status == 0) { - char *printer_name; /* Associate the returned printer handle with a name */ - printer_name = dcerpc_smb_fetch_priv( - di, SPOOLSS_ADDPRINTEREX, NULL); - - if (printer_name) { + if (dcv->private_data) { if (check_col(pinfo->cinfo, COL_INFO)) col_append_fstr( pinfo->cinfo, COL_INFO, ", %s", - printer_name); + (char *)dcv->private_data); - dcerpc_smb_store_pol(policy_hnd, printer_name, - pinfo->fd->num, 0); - } + dcerpc_smb_store_pol( + policy_hnd, dcv->private_data, pinfo->fd->num, 0); - g_free(printer_name); + g_free(dcv->private_data); + dcv->private_data = NULL; + } } dcerpc_smb_check_long_frame(tvb, offset, pinfo, tree); @@ -2188,7 +2118,7 @@ static int SpoolssEnumPrinterData_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; const guint8 *policy_hnd; /* Update informational fields */ @@ -2196,11 +2126,9 @@ static int SpoolssEnumPrinterData_q(tvbuff_t *tvb, int offset, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "EnumPrinterData request"); - dcerpc_smb_store_q(di, SPOOLSS_ENUMPRINTERDATA, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_ENUMPRINTERDATA))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -2224,7 +2152,7 @@ static int SpoolssEnumPrinterData_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; guint32 data_size, type, value_size; int uint16s_offset; char *text; @@ -2232,14 +2160,11 @@ static int SpoolssEnumPrinterData_r(tvbuff_t *tvb, int offset, /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "EnumPrinterData response"); + col_set_str(pinfo->cinfo, COL_INFO, "EnumPrinterData response"); - dcerpc_smb_store_r(di, SPOOLSS_ENUMPRINTERDATA, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_ENUMPRINTERDATA))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -2288,7 +2213,7 @@ static int SpoolssEnumPrinters_q(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; guint32 ptr, level; /* Update informational fields */ @@ -2296,11 +2221,9 @@ static int SpoolssEnumPrinters_q(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "EnumPrinters request"); - dcerpc_smb_store_q(di, SPOOLSS_ENUMPRINTERS, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_ENUMPRINTERS))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -2331,18 +2254,16 @@ static int SpoolssEnumPrinters_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "EnumPrinters response"); - dcerpc_smb_store_r(di, SPOOLSS_ENUMPRINTERS, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_ENUMPRINTERS))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -2369,19 +2290,16 @@ static int SpoolssAddPrinterDriver_q(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "AddPrinterDriver request"); - - dcerpc_smb_store_q(di, SPOOLSS_ADDPRINTERDRIVER, pinfo->fd->num); + col_set_str(pinfo->cinfo, COL_INFO, "AddPrinterDriver request"); - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_ADDPRINTERDRIVER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -2395,19 +2313,16 @@ static int SpoolssAddPrinterDriver_r(tvbuff_t *tvb, int offset, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "AddPrinterDriver response"); - - dcerpc_smb_store_r(di, SPOOLSS_ADDPRINTERDRIVER, pinfo->fd->num); + col_set_str(pinfo->cinfo, COL_INFO, "AddPrinterDriver response"); - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_ADDPRINTERDRIVER))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -2504,21 +2419,18 @@ static int SpoolssAddForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; const guint8 *policy_hnd; guint32 level; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "AddForm request"); - - dcerpc_smb_store_q(di, SPOOLSS_ADDFORM, pinfo->fd->num); + col_set_str(pinfo->cinfo, COL_INFO, "AddForm request"); - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_ADDFORM))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -2533,7 +2445,7 @@ static int SpoolssAddForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, /* Store info level to match with response packet */ - dcerpc_smb_store_priv(di, SPOOLSS_ADDFORM, &level, sizeof(level)); + dcv->private_data = (void *)level; offset = prs_struct_and_referents(tvb, offset, pinfo, tree, prs_FORM_CTR, NULL, NULL); @@ -2547,18 +2459,16 @@ static int SpoolssAddForm_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "AddForm response"); - dcerpc_smb_store_r(di, SPOOLSS_ADDFORM, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_ADDFORM))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -2577,7 +2487,7 @@ static int SpoolssDeleteForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; const guint8 *policy_hnd; char *form_name; @@ -2586,11 +2496,9 @@ static int SpoolssDeleteForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "DeleteForm request"); - dcerpc_smb_store_q(di, SPOOLSS_DELETEFORM, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_DELETEFORM))) + if (dcv->rep_frame != -1) proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -2605,6 +2513,8 @@ static int SpoolssDeleteForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", form_name); + g_free(form_name); + dcerpc_smb_check_long_frame(tvb, offset, pinfo, tree); return offset; @@ -2614,18 +2524,16 @@ static int SpoolssDeleteForm_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "DeleteForm response"); - dcerpc_smb_store_r(di, SPOOLSS_DELETEFORM, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_DELETEFORM))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -2644,7 +2552,7 @@ static int SpoolssSetForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; const guint8 *policy_hnd; guint32 level; char *form_name; @@ -2652,14 +2560,11 @@ static int SpoolssSetForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, - "SetForm request"); + col_set_str(pinfo->cinfo, COL_INFO, "SetForm request"); - dcerpc_smb_store_q(di, SPOOLSS_SETFORM, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_SETFORM))) - proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + if (dcv->rep_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -2671,12 +2576,16 @@ static int SpoolssSetForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, prs_UNISTR2_dp, (void **)&form_name, NULL); + CLEANUP_PUSH(g_free, form_name); + offset = prs_uint32(tvb, offset, pinfo, tree, &level, "Level"); if (check_col(pinfo->cinfo, COL_INFO)) col_append_fstr(pinfo->cinfo, COL_INFO, ", %s, level %d", form_name, level); + CLEANUP_CALL_AND_POP; + offset = prs_struct_and_referents(tvb, offset, pinfo, tree, prs_FORM_CTR, NULL, NULL); @@ -2689,7 +2598,7 @@ static int SpoolssSetForm_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; proto_item *info_item; /* Update informational fields */ @@ -2697,11 +2606,9 @@ static int SpoolssSetForm_r(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "SetForm response"); - dcerpc_smb_store_r(di, SPOOLSS_SETFORM, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_SETFORM))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -2720,7 +2627,8 @@ static int SpoolssGetForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num, level; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; + guint32 level; const guint8 *policy_hnd; char *form_name; @@ -2729,11 +2637,9 @@ static int SpoolssGetForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "GetForm request"); - dcerpc_smb_store_q(di, SPOOLSS_GETFORM, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_GETFORM))) + if (dcv->rep_frame != -1) proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -2745,14 +2651,18 @@ static int SpoolssGetForm_q(tvbuff_t *tvb, int offset, packet_info *pinfo, prs_UNISTR2_dp, (void **)&form_name, NULL); + CLEANUP_PUSH(g_free, form_name); + offset = prs_uint32(tvb, offset, pinfo, tree, &level, "Level"); - dcerpc_smb_store_priv(di, SPOOLSS_GETFORM, &level, sizeof(level)); + dcv->private_data = (void *)level; if (check_col(pinfo->cinfo, COL_INFO)) col_append_fstr(pinfo->cinfo, COL_INFO, ", %s, level %d", form_name, level); + CLEANUP_CALL_AND_POP; + offset = prs_struct_and_referents(tvb, offset, pinfo, tree, prs_BUFFER, NULL, NULL); @@ -2767,7 +2677,7 @@ static int SpoolssGetForm_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; void **data_list; struct BUFFER_DATA *bd = NULL; @@ -2776,11 +2686,9 @@ static int SpoolssGetForm_r(tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "GetForm response"); - dcerpc_smb_store_r(di, SPOOLSS_GETFORM, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_GETFORM))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ @@ -2795,14 +2703,9 @@ static int SpoolssGetForm_r(tvbuff_t *tvb, int offset, packet_info *pinfo, CLEANUP_PUSH(g_free, bd); if (bd && bd->tree) { - guint32 *level; - - level = dcerpc_smb_fetch_priv(di, SPOOLSS_GETFORM, NULL); - - if (!level) - goto done; + guint32 level = (guint32)dcv->private_data; - switch(*level) { + switch(level) { case 1: { int struct_start = bd->offset; GList *dp_list = NULL; @@ -2815,12 +2718,11 @@ static int SpoolssGetForm_r(tvbuff_t *tvb, int offset, packet_info *pinfo, default: proto_tree_add_text( bd->tree, bd->tvb, bd->offset, 0, - "[Unknown info level %d]", *level); + "[Unknown info level %d]", level); break; } } - done: CLEANUP_CALL_AND_POP; @@ -2838,11 +2740,17 @@ static int SpoolssGetForm_r(tvbuff_t *tvb, int offset, packet_info *pinfo, static int SpoolssGeneric_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { + dcerpc_info *di = (dcerpc_info *)pinfo->private_data; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; int len = tvb_length(tvb); proto_tree_add_text(tree, tvb, offset, 0, "[Unimplemented dissector: SPOOLSS]"); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); + prs_werror(tvb, len - 4, pinfo, tree, NULL); return offset; @@ -2862,18 +2770,16 @@ static int SpoolssFoo_q(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 response_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "Foo request"); - dcerpc_smb_store_q(di, SPOOLSS_FOO, pinfo->fd->num); - - if ((response_num = dcerpc_smb_fetch_r(di, SPOOLSS_FOO))) + if (dcv->rep_frame != -1) proto_tree_add_text(tree, tvb, offset, 0, - "Response in frame %d", response_num); + "Response in frame %d", dcv->rep_frame); /* Parse packet */ @@ -2886,18 +2792,16 @@ static int SpoolssFoo_r(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep) { dcerpc_info *di = (dcerpc_info *)pinfo->private_data; - guint32 request_num; + dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data; /* Update informational fields */ if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "Foo response"); - dcerpc_smb_store_r(di, SPOOLSS_FOO, pinfo->fd->num); - - if ((request_num = dcerpc_smb_fetch_q(di, SPOOLSS_FOO))) - proto_tree_add_text(tree, tvb, offset, 0, - "Request in frame %d", request_num); + if (dcv->req_frame != -1) + proto_tree_add_text(tree, tvb, offset, 0, + "Request in frame %d", dcv->req_frame); /* Parse packet */ |