aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto_data.c
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2016-09-16 22:15:57 +0200
committerPascal Quantin <pascal.quantin@gmail.com>2016-09-17 15:46:36 +0000
commit22257e8cf5a497cd16dd7336a9b8dd224285ee39 (patch)
tree72fa8ab79f10aba2e3d4465933f5c7d0bac6684b /epan/proto_data.c
parent2832f4e97d77324b4e46aac40dae0ce898ae559d (diff)
p_XXX_proto_data: only allow the use of pinfo and file scopes
Those are the only ones meaningful. Let's convert the buggy dissectors and add an assert to avoid the misuse of the pool parameter in the future Change-Id: I65f470b757f163f11a25cd352ffe168d1f8a86d3 Reviewed-on: https://code.wireshark.org/review/17748 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan/proto_data.c')
-rw-r--r--epan/proto_data.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/epan/proto_data.c b/epan/proto_data.c
index d17b2a449e..597ab74b10 100644
--- a/epan/proto_data.c
+++ b/epan/proto_data.c
@@ -77,9 +77,11 @@ p_add_proto_data(wmem_allocator_t *tmp_scope, struct _packet_info* pinfo, int pr
if (tmp_scope == pinfo->pool) {
scope = tmp_scope;
proto_list = &pinfo->proto_data;
- } else {
+ } else if (tmp_scope == wmem_file_scope()) {
scope = wmem_file_scope();
proto_list = &pinfo->fd->pfd;
+ } else {
+ DISSECTOR_ASSERT(!"invalid wmem scope");
}
p1 = (proto_data_t *)wmem_alloc(scope, sizeof(proto_data_t));
@@ -104,8 +106,10 @@ p_get_proto_data(wmem_allocator_t *scope, struct _packet_info* pinfo, int proto,
if (scope == pinfo->pool) {
item = g_slist_find_custom(pinfo->proto_data, &temp, p_compare);
- } else {
+ } else if (scope == wmem_file_scope()) {
item = g_slist_find_custom(pinfo->fd->pfd, &temp, p_compare);
+ } else {
+ DISSECTOR_ASSERT(!"invalid wmem scope");
}
if (item) {
@@ -130,9 +134,11 @@ p_remove_proto_data(wmem_allocator_t *scope, struct _packet_info* pinfo, int pro
if (scope == pinfo->pool) {
item = g_slist_find_custom(pinfo->fd->pfd, &temp, p_compare);
proto_list = &pinfo->proto_data;
- } else {
+ } else if (scope == wmem_file_scope()) {
item = g_slist_find_custom(pinfo->fd->pfd, &temp, p_compare);
proto_list = &pinfo->fd->pfd;
+ } else {
+ DISSECTOR_ASSERT(!"invalid wmem scope");
}
if (item) {
@@ -146,8 +152,10 @@ p_get_proto_name_and_key(wmem_allocator_t *scope, struct _packet_info* pinfo, gu
if (scope == pinfo->pool) {
temp = (proto_data_t *)g_slist_nth_data(pinfo->proto_data, pfd_index);
- } else {
+ } else if (scope == wmem_file_scope()) {
temp = (proto_data_t *)g_slist_nth_data(pinfo->fd->pfd, pfd_index);
+ } else {
+ DISSECTOR_ASSERT(!"invalid wmem scope");
}
return wmem_strdup_printf(wmem_packet_scope(),"[%s, key %u]",proto_get_protocol_name(temp->proto), temp->key);