Ensure dissector data parameter is used instead of pinfo->private_data when passing data between dissectors using the "media_type" subdissector.
Change-Id: I82cbfed770b41404bc42cb6a4413db07d04dffdc Reviewed-on: https://code.wireshark.org/review/5462 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
7f22ce7f66
commit
e3a04bb392
|
@ -1267,8 +1267,6 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
* There's stuff left over; process it.
|
||||
*/
|
||||
tvbuff_t *next_tvb;
|
||||
void *save_private_data = NULL;
|
||||
gboolean private_data_changed = FALSE;
|
||||
gint chunks_decoded = 0;
|
||||
char *media_str = NULL;
|
||||
|
||||
|
@ -1434,15 +1432,9 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
* Content-Type value. Is there any subdissector
|
||||
* for that content type?
|
||||
*/
|
||||
save_private_data = pinfo->private_data;
|
||||
private_data_changed = TRUE;
|
||||
if (headers.content_type_parameters)
|
||||
media_str = wmem_strdup(wmem_packet_scope(), headers.content_type_parameters);
|
||||
|
||||
if (headers.content_type_parameters) {
|
||||
pinfo->private_data = wmem_strdup(wmem_packet_scope(), headers.content_type_parameters);
|
||||
media_str = (char*)pinfo->private_data;
|
||||
}
|
||||
else
|
||||
pinfo->private_data = NULL;
|
||||
/*
|
||||
* Calling the string handle for the media type
|
||||
* dissector table will set pinfo->match_string
|
||||
|
@ -1477,7 +1469,7 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
/*
|
||||
* We have a subdissector - call it.
|
||||
*/
|
||||
dissected = call_dissector_only(handle, next_tvb, pinfo, tree, NULL);
|
||||
dissected = call_dissector_only(handle, next_tvb, pinfo, tree, media_str);
|
||||
if (!dissected)
|
||||
expert_add_info(pinfo, http_tree, &ei_http_subdissector_failed);
|
||||
}
|
||||
|
@ -1513,12 +1505,6 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
}
|
||||
|
||||
body_dissected:
|
||||
/*
|
||||
* Do *not* attempt at freeing the private data;
|
||||
* it may be in use by subdissectors.
|
||||
*/
|
||||
if (private_data_changed) /*restore even NULL value*/
|
||||
pinfo->private_data = save_private_data;
|
||||
/*
|
||||
* We've processed "datalen" bytes worth of data
|
||||
* (which may be no data at all); advance the
|
||||
|
|
|
@ -806,15 +806,9 @@ dissect_imf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
/* now dissect the MIME based upon the content type */
|
||||
|
||||
if(content_type_str && media_type_dissector_table) {
|
||||
void* pd_save;
|
||||
pd_save = pinfo->private_data;
|
||||
pinfo->private_data = parameters;
|
||||
|
||||
next_tvb = tvb_new_subset_remaining(tvb, end_offset);
|
||||
|
||||
dissector_try_string(media_type_dissector_table, content_type_str, next_tvb, pinfo, tree, NULL);
|
||||
|
||||
pinfo->private_data = pd_save;
|
||||
dissector_try_string(media_type_dissector_table, content_type_str, next_tvb, pinfo, tree, parameters);
|
||||
} else {
|
||||
|
||||
/* just show the lines or highlight the rest of the buffer as message text */
|
||||
|
|
|
@ -10684,7 +10684,7 @@ dissect_bicc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
}
|
||||
|
||||
static int
|
||||
dissect_application_isup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
||||
dissect_application_isup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
|
||||
{
|
||||
/* Set up structures needed to add the protocol subtree and manage it */
|
||||
proto_item *ti;
|
||||
|
@ -10694,8 +10694,8 @@ dissect_application_isup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
|
|||
gchar *content_type_parameter_str;
|
||||
guint8 itu_isup_variant = ISUP_ITU_STANDARD_VARIANT; /* Default */
|
||||
|
||||
if (pinfo->private_data) {
|
||||
content_type_parameter_str = ascii_strdown_inplace((gchar *)pinfo->private_data);
|
||||
if (data) {
|
||||
content_type_parameter_str = ascii_strdown_inplace((gchar *)data);
|
||||
if (strstr(content_type_parameter_str, "ansi")) {
|
||||
isup_standard = ANSI_STANDARD;
|
||||
col_append_str(pinfo->cinfo, COL_PROTOCOL, "/ISUP(ANSI)");
|
||||
|
|
|
@ -2049,16 +2049,12 @@ static int dissect_media( const gchar* fullmediatype, tvbuff_t * tvb, packet_inf
|
|||
gchar *mediatype = wmem_strdup(wmem_packet_scope(), fullmediatype);
|
||||
gchar *parms_at = strchr(mediatype, ';');
|
||||
const char *save_match_string = pinfo->match_string;
|
||||
void * save_private_data = pinfo->private_data;
|
||||
char *media_str = NULL;
|
||||
|
||||
/* Based upon what is done in packet-media.c we set up type and params */
|
||||
if (NULL != parms_at) {
|
||||
pinfo->private_data = wmem_strdup( wmem_packet_scope(), parms_at + 1 );
|
||||
media_str = (char*)pinfo->private_data;
|
||||
media_str = wmem_strdup( wmem_packet_scope(), parms_at + 1 );
|
||||
*parms_at = '\0';
|
||||
} else {
|
||||
pinfo->private_data = NULL;
|
||||
}
|
||||
|
||||
/* Set the version that goes to packet-media.c before converting case */
|
||||
|
@ -2088,7 +2084,7 @@ static int dissect_media( const gchar* fullmediatype, tvbuff_t * tvb, packet_inf
|
|||
}
|
||||
}
|
||||
} else {
|
||||
dissected = dissector_try_string(media_type_dissector_table, mediatype, tvb, pinfo, tree, NULL) ? tvb_length(tvb) : 0;
|
||||
dissected = dissector_try_string(media_type_dissector_table, mediatype, tvb, pinfo, tree, media_str) ? tvb_length(tvb) : 0;
|
||||
|
||||
if( dissected != (int) tvb_length(tvb) ) {
|
||||
/* g_message( "%s : %d expected, %d dissected", mediatype, tvb_length(tvb), dissected ); */
|
||||
|
@ -2100,12 +2096,11 @@ static int dissect_media( const gchar* fullmediatype, tvbuff_t * tvb, packet_inf
|
|||
}
|
||||
|
||||
pinfo->match_string = save_match_string;
|
||||
pinfo->private_data = save_private_data;
|
||||
}
|
||||
|
||||
if(0 == dissected) {
|
||||
/* display it as raw data */
|
||||
dissected = call_dissector_only(data_handle, tvb, pinfo, tree, NULL);
|
||||
dissected = call_dissector(data_handle, tvb, pinfo, tree);
|
||||
}
|
||||
|
||||
return dissected;
|
||||
|
|
|
@ -689,13 +689,10 @@ dissect_msrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
|
|||
/* give the content type parameters to sub dissectors */
|
||||
|
||||
if ( media_type_str_lower_case != NULL ) {
|
||||
void *save_private_data = pinfo->private_data;
|
||||
pinfo->private_data = content_type_parameter_str;
|
||||
found_match = dissector_try_string(media_type_dissector_table,
|
||||
media_type_str_lower_case,
|
||||
next_tvb, pinfo,
|
||||
msrp_data_tree, NULL);
|
||||
pinfo->private_data = save_private_data;
|
||||
msrp_data_tree, content_type_parameter_str);
|
||||
/* If no match dump as text */
|
||||
}
|
||||
if ( found_match != TRUE )
|
||||
|
|
|
@ -395,7 +395,7 @@ static char *find_parameter(char *parameters, const char *key, int *retlen)
|
|||
* leading hyphens. (quote from rfc2046)
|
||||
*/
|
||||
static multipart_info_t *
|
||||
get_multipart_info(packet_info *pinfo)
|
||||
get_multipart_info(packet_info *pinfo, const char *str)
|
||||
{
|
||||
const char *start;
|
||||
int len = 0;
|
||||
|
@ -404,7 +404,7 @@ get_multipart_info(packet_info *pinfo)
|
|||
char *parameters;
|
||||
gint dummy;
|
||||
|
||||
if ((type == NULL) || (pinfo->private_data == NULL)) {
|
||||
if ((type == NULL) || (str == NULL)) {
|
||||
/*
|
||||
* We need both a content type AND parameters
|
||||
* for multipart dissection.
|
||||
|
@ -413,7 +413,7 @@ get_multipart_info(packet_info *pinfo)
|
|||
}
|
||||
|
||||
/* Clean up the parameters */
|
||||
parameters = unfold_and_compact_mime_header((const char *)pinfo->private_data, &dummy);
|
||||
parameters = unfold_and_compact_mime_header(str, &dummy);
|
||||
|
||||
start = find_parameter(parameters, "boundary=", &len);
|
||||
|
||||
|
@ -709,7 +709,6 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, const guint8 *boundary,
|
|||
/*
|
||||
* subdissection
|
||||
*/
|
||||
void *save_private_data = pinfo->private_data;
|
||||
gboolean dissected;
|
||||
|
||||
/*
|
||||
|
@ -725,18 +724,17 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, const guint8 *boundary,
|
|||
|
||||
}
|
||||
|
||||
pinfo->private_data = parameters;
|
||||
/*
|
||||
* First try the dedicated multipart dissector table
|
||||
*/
|
||||
dissected = dissector_try_string(multipart_media_subdissector_table,
|
||||
content_type_str, tmp_tvb, pinfo, subtree, NULL);
|
||||
content_type_str, tmp_tvb, pinfo, subtree, parameters);
|
||||
if (! dissected) {
|
||||
/*
|
||||
* Fall back to the default media dissector table
|
||||
*/
|
||||
dissected = dissector_try_string(media_type_dissector_table,
|
||||
content_type_str, tmp_tvb, pinfo, subtree, NULL);
|
||||
content_type_str, tmp_tvb, pinfo, subtree, parameters);
|
||||
}
|
||||
if (! dissected) {
|
||||
const char *save_match_string = pinfo->match_string;
|
||||
|
@ -744,7 +742,6 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, const guint8 *boundary,
|
|||
call_dissector_with_data(media_handle, tmp_tvb, pinfo, subtree, parameters);
|
||||
pinfo->match_string = save_match_string;
|
||||
}
|
||||
pinfo->private_data = save_private_data;
|
||||
parameters = NULL; /* Shares same memory as content_type_str */
|
||||
} else {
|
||||
call_dissector(data_handle, tmp_tvb, pinfo, subtree);
|
||||
|
@ -772,12 +769,12 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, const guint8 *boundary,
|
|||
* Call this method to actually dissect the multipart body.
|
||||
* NOTE - Only do so if a boundary string has been found!
|
||||
*/
|
||||
static int dissect_multipart(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
||||
static int dissect_multipart(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
|
||||
{
|
||||
proto_tree *subtree;
|
||||
proto_item *ti;
|
||||
proto_item *type_ti;
|
||||
multipart_info_t *m_info = get_multipart_info(pinfo);
|
||||
multipart_info_t *m_info = get_multipart_info(pinfo, (const char*)data);
|
||||
gint header_start = 0;
|
||||
guint8 *boundary;
|
||||
gint boundary_len;
|
||||
|
|
|
@ -3727,9 +3727,6 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
|
|||
|
||||
/* give the content type parameters to sub dissectors */
|
||||
if ( media_type_str_lower_case != NULL ) {
|
||||
void *save_private_data = pinfo->private_data;
|
||||
pinfo->private_data = content_type_parameter_str;
|
||||
|
||||
/* SDP needs a transport layer to determine request/response */
|
||||
if (!strcmp(media_type_str_lower_case, "application/sdp")) {
|
||||
/* Resends don't count */
|
||||
|
@ -3777,7 +3774,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
|
|||
found_match = dissector_try_string(media_type_dissector_table,
|
||||
media_type_str_lower_case,
|
||||
next_tvb, pinfo,
|
||||
message_body_tree, NULL);
|
||||
message_body_tree, content_type_parameter_str);
|
||||
DENDENT();
|
||||
DPRINT(("done calling dissector_try_string() with found_match=%s",
|
||||
found_match?"TRUE":"FALSE"));
|
||||
|
@ -3790,12 +3787,11 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
|
|||
found_match = dissector_try_string(media_type_dissector_table,
|
||||
"multipart/",
|
||||
next_tvb, pinfo,
|
||||
message_body_tree, NULL);
|
||||
message_body_tree, content_type_parameter_str);
|
||||
DENDENT();
|
||||
DPRINT(("done calling dissector_try_string() with found_match=%s",
|
||||
found_match?"TRUE":"FALSE"));
|
||||
}
|
||||
pinfo->private_data = save_private_data;
|
||||
/* If no match dump as text */
|
||||
}
|
||||
if ( found_match != TRUE )
|
||||
|
|
|
@ -746,9 +746,7 @@ static int dissect_spdy_data_payload(tvbuff_t *tvb,
|
|||
tvbuff_t *next_tvb = NULL;
|
||||
tvbuff_t *data_tvb = NULL;
|
||||
spdy_stream_info_t *si = NULL;
|
||||
void *save_private_data = NULL;
|
||||
guint8 *copied_data;
|
||||
gboolean private_data_changed = FALSE;
|
||||
gboolean is_single_chunk = FALSE;
|
||||
gboolean have_entire_body;
|
||||
char *media_str = NULL;
|
||||
|
@ -904,14 +902,8 @@ static int dissect_spdy_data_payload(tvbuff_t *tvb,
|
|||
* Content-Type value. Is there any subdissector
|
||||
* for that content type?
|
||||
*/
|
||||
save_private_data = pinfo->private_data;
|
||||
private_data_changed = TRUE;
|
||||
|
||||
if (si->content_type_parameters) {
|
||||
pinfo->private_data = wmem_strdup(wmem_packet_scope(), si->content_type_parameters);
|
||||
media_str = (char*)pinfo->private_data;
|
||||
} else {
|
||||
pinfo->private_data = NULL;
|
||||
media_str = wmem_strdup(wmem_packet_scope(), si->content_type_parameters);
|
||||
}
|
||||
/*
|
||||
* Calling the string handle for the media type
|
||||
|
@ -926,7 +918,7 @@ static int dissect_spdy_data_payload(tvbuff_t *tvb,
|
|||
/*
|
||||
* We have a subdissector - call it.
|
||||
*/
|
||||
dissected = call_dissector(handle, data_tvb, pinfo, spdy_tree);
|
||||
dissected = call_dissector_with_data(handle, data_tvb, pinfo, spdy_tree, media_str);
|
||||
} else {
|
||||
dissected = FALSE;
|
||||
}
|
||||
|
@ -943,18 +935,12 @@ static int dissect_spdy_data_payload(tvbuff_t *tvb,
|
|||
}
|
||||
|
||||
body_dissected:
|
||||
/*
|
||||
* Do *not* attempt at freeing the private data;
|
||||
* it may be in use by subdissectors.
|
||||
*/
|
||||
if (private_data_changed) { /*restore even NULL value*/
|
||||
pinfo->private_data = save_private_data;
|
||||
}
|
||||
/*
|
||||
* We've processed frame->length bytes worth of data
|
||||
* (which may be no data at all); advance the
|
||||
* offset past whatever data we've processed.
|
||||
*/
|
||||
;
|
||||
}
|
||||
return frame->length;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue