aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2014-06-22 15:31:01 -0400
committerEvan Huus <eapache@gmail.com>2014-06-22 20:23:36 +0000
commitdfe7e71ec55573989e524e78350f406994f2b417 (patch)
tree9bf52e169725449c4f32f8eb20b1dcc82607b515 /epan
parent38e0ad08d3a2e41bc5c7c44fac0acc3b1d8bb650 (diff)
Fix a leak in the SCTP dissector
use wmem instead of glib Change-Id: I326d2dd71b13ae45b4434c86fdacf9f3cec6c069 Reviewed-on: https://code.wireshark.org/review/2557 Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-sctp.c73
1 files changed, 44 insertions, 29 deletions
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index afdd0a5193..90376861b3 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -507,7 +507,7 @@ typedef struct _infodata_t {
guint16 direction;
} infodata_t;
-static GSList *assoc_info_list = NULL;
+static wmem_list_t *assoc_info_list = NULL;
static guint num_assocs = 0;
UAT_CSTRING_CB_DEF(type_fields, type_name, type_field_t)
@@ -656,34 +656,38 @@ static infodata_t
find_assoc_index(assoc_info_t* tmpinfo)
{
assoc_info_t *info = NULL;
- GSList* list;
+ wmem_list_frame_t *elem;
gboolean cmp = FALSE;
infodata_t inf;
- if ((list = assoc_info_list) != NULL) {
- while (list) {
- cmp = sctp_assoc_vtag_cmp(tmpinfo, (assoc_info_t*)(list->data));
- if (cmp < ASSOC_NOT_FOUND) {
- info = (assoc_info_t *)(list->data);
- switch (cmp)
- {
- case FORWARD_ADD_FORWARD_VTAG:
- case BACKWARD_ADD_FORWARD_VTAG:
- info->verification_tag1 = tmpinfo->verification_tag1;
- case BACKWARD_ADD_BACKWARD_VTAG:
- info->verification_tag2 = tmpinfo->verification_tag1;
- }
- if (cmp == FORWARD_STREAM || cmp == FORWARD_ADD_FORWARD_VTAG) {
- info->direction = 1;
- } else {
- info->direction = 2;
- }
- inf.assoc_index = info->assoc_index;
- inf.direction = info->direction;
- return inf;
+ if (assoc_info_list == NULL) {
+ assoc_info_list = wmem_list_new(wmem_file_scope());
+ }
+
+ elem = wmem_list_head(assoc_info_list);
+
+ while (elem) {
+ info = (assoc_info_t*) wmem_list_frame_data(elem);
+ cmp = sctp_assoc_vtag_cmp(tmpinfo, info);
+ if (cmp < ASSOC_NOT_FOUND) {
+ switch (cmp)
+ {
+ case FORWARD_ADD_FORWARD_VTAG:
+ case BACKWARD_ADD_FORWARD_VTAG:
+ info->verification_tag1 = tmpinfo->verification_tag1;
+ case BACKWARD_ADD_BACKWARD_VTAG:
+ info->verification_tag2 = tmpinfo->verification_tag1;
+ }
+ if (cmp == FORWARD_STREAM || cmp == FORWARD_ADD_FORWARD_VTAG) {
+ info->direction = 1;
+ } else {
+ info->direction = 2;
}
- list = g_slist_next(list);
+ inf.assoc_index = info->assoc_index;
+ inf.direction = info->direction;
+ return inf;
}
+ elem = wmem_list_frame_next(elem);
}
info = wmem_new0(wmem_file_scope(), assoc_info_t);
info->assoc_index = num_assocs;
@@ -693,7 +697,7 @@ find_assoc_index(assoc_info_t* tmpinfo)
info->verification_tag2 = tmpinfo->verification_tag2;
info->initiate_tag = tmpinfo->initiate_tag;
num_assocs++;
- assoc_info_list = g_slist_prepend(assoc_info_list, info);
+ wmem_list_prepend(assoc_info_list, info);
inf.assoc_index = info->assoc_index;
inf.direction = 1;
return inf;
@@ -2539,10 +2543,8 @@ static void
sctp_init(void)
{
frag_table_init();
- if (num_assocs > 0) {
- num_assocs = 0;
- assoc_info_list = NULL;
- }
+ num_assocs = 0;
+ assoc_info_list = NULL;
}
@@ -4845,3 +4847,16 @@ proto_reg_handoff_sctp(void)
dissector_add_uint("ip.proto", IP_PROTO_SCTP, sctp_handle);
dissector_add_uint("udp.port", UDP_TUNNELING_PORT, sctp_handle);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */