diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2018-03-06 22:33:49 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-03-07 06:06:17 +0000 |
commit | 05c4705a19448646ca316ba3b1eb333a05482956 (patch) | |
tree | 7428b7f9ace3291ad2461cb8cebf2c9b4c6af1db /epan/dissectors/packet-multipart.c | |
parent | 4581eb2de2e5aacfc9a2224df181010dc8e6141b (diff) |
multipart: use packet scope memory to avoid leaking in case an exception is triggered by subdissectors
Bug: 14486
Change-Id: I275f8c962f126ad55fc7086012e7b67cc0dc60b3
Reviewed-on: https://code.wireshark.org/review/26291
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-multipart.c')
-rw-r--r-- | epan/dissectors/packet-multipart.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/epan/dissectors/packet-multipart.c b/epan/dissectors/packet-multipart.c index c3dc824f43..ea3291dc71 100644 --- a/epan/dissectors/packet-multipart.c +++ b/epan/dissectors/packet-multipart.c @@ -554,6 +554,7 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, gchar *content_encoding_str = NULL; char *filename = NULL; char *mimetypename = NULL; + char *tmp; gboolean last_field = FALSE; gboolean is_raw_data = FALSE; @@ -677,7 +678,11 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, proto_item_append_text(ti, " (%s)", content_type_str); /* find the "name" parameter in case we don't find a content disposition "filename" */ - mimetypename = ws_find_media_type_parameter(message_info.media_str, "name"); + tmp = ws_find_media_type_parameter(message_info.media_str, "name"); + if (tmp) { + mimetypename = wmem_strdup(wmem_packet_scope(), tmp); + g_free(tmp); + } if(strncmp(content_type_str, "application/octet-stream", sizeof("application/octet-stream")-1) == 0) { @@ -708,7 +713,11 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, case POS_CONTENT_DISPOSITION: { /* find the "filename" parameter */ - filename = ws_find_media_type_parameter(value_str, "filename"); + tmp = ws_find_media_type_parameter(value_str, "filename"); + if (tmp) { + filename = wmem_strdup(wmem_packet_scope(), tmp); + g_free(tmp); + } } break; default: @@ -802,9 +811,6 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, proto_tree_add_item(tree, hf_multipart_boundary, tvb, boundary_start, boundary_line_len, ENC_NA|ENC_ASCII); } - g_free(filename); - g_free(mimetypename); - return boundary_start + boundary_line_len; } } |