diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2005-12-07 21:08:51 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2005-12-07 21:08:51 +0000 |
commit | 55d5c5cc6649c58e27d9441d3161b72a391af82d (patch) | |
tree | 632d5ade2e85983b61e1919242205238038d324d | |
parent | f65a00b5f40af5af24ce953284769e1d57602a26 (diff) |
Avoid dereferencing pointers to the message, context and transaction object if they have not been created.
svn path=/trunk/; revision=16725
-rw-r--r-- | asn1/h248/packet-h248-template.c | 17 | ||||
-rw-r--r-- | epan/dissectors/packet-h248.c | 23 |
2 files changed, 37 insertions, 3 deletions
diff --git a/asn1/h248/packet-h248-template.c b/asn1/h248/packet-h248-template.c index e7a100f189..f997767fbe 100644 --- a/asn1/h248/packet-h248-template.c +++ b/asn1/h248/packet-h248-template.c @@ -945,6 +945,8 @@ static h248_msg_t* h248_msg(packet_info* pinfo, int offset) { static h248_trx_t* h248_trx(h248_msg_t* m ,guint32 t_id , h248_trx_type_t type) { h248_trx_t* t = NULL; h248_trx_msg_t* trxmsg; + + if ( !m ) return NULL; if (keep_persistent_data) { if (m->commited) { @@ -1013,6 +1015,8 @@ static h248_ctx_t* h248_ctx(h248_msg_t* m, h248_trx_t* t, guint32 c_id) { h248_ctx_t* context = NULL; h248_ctx_t** context_p = NULL; + if ( !m || !t ) return NULL; + if (keep_persistent_data) { if (m->commited) { gchar* key = ep_strdup_printf("%s:%.8x",m->addr_label,c_id); @@ -1046,6 +1050,7 @@ static h248_ctx_t* h248_ctx(h248_msg_t* m, h248_trx_t* t, guint32 c_id) { } } else { gchar* key = ep_strdup_printf("C%s:%.8x",m->addr_label,c_id); + if (( context = g_hash_table_lookup(ctxs_by_trx,t->key) )) { if (( context_p = g_hash_table_lookup(ctxs,key) )) { @@ -1108,6 +1113,8 @@ static h248_cmd_t* h248_cmd(h248_msg_t* m, h248_trx_t* t, h248_ctx_t* c, h248_cm h248_cmd_msg_t* cmdtrx; h248_cmd_msg_t* cmdctx; + if ( !m || !t || !c) return NULL; + if (keep_persistent_data) { if (m->commited) { DISSECTOR_ASSERT(t->cmds != NULL); @@ -1172,6 +1179,8 @@ static h248_cmd_t* h248_cmd(h248_msg_t* m, h248_trx_t* t, h248_ctx_t* c, h248_cm static void h248_cmd_add_term(h248_cmd_t* c, h248_term_t* t) { h248_terms_t* ct; + if ( !c ) return; + if (keep_persistent_data) { if ( c->msg->commited ) { return; @@ -1214,6 +1223,8 @@ static gchar* h248_cmd_to_str(h248_cmd_t* c) { gchar* s = "-"; h248_terms_t* term; + if ( !c ) return "-"; + switch (c->type) { case H248_CMD_NONE: return "-"; @@ -1295,6 +1306,9 @@ static gchar* h248_cmd_to_str(h248_cmd_t* c) { static gchar* h248_trx_to_str(h248_msg_t* m, h248_trx_t* t) { gchar* s = ep_strdup_printf("T %x { ",t->id); h248_cmd_msg_t* c; + + if ( !m || !t ) return "-"; + if (t->cmds) { if (t->cmds->cmd->ctx) { @@ -1320,6 +1334,8 @@ static gchar* h248_msg_to_str(h248_msg_t* m) { h248_trx_msg_t* t; gchar* s = ""; + if ( !m ) return "-"; + for (t = m->trxs; t; t = t->next) { s = ep_strdup_printf("%s %s",s,h248_trx_to_str(m,t->trx)); }; @@ -1340,6 +1356,7 @@ static void analyze_h248_msg(h248_msg_t* m) { h248_ctxs_t* ctx_node; h248_cmd_msg_t* c; + for (t = m->trxs; t; t = t->next) { for (c = t->trx->cmds; c; c = c->next) { h248_ctx_t* ctx = c->cmd->ctx; diff --git a/epan/dissectors/packet-h248.c b/epan/dissectors/packet-h248.c index e93492af6c..2cab71107f 100644 --- a/epan/dissectors/packet-h248.c +++ b/epan/dissectors/packet-h248.c @@ -1351,6 +1351,8 @@ static h248_msg_t* h248_msg(packet_info* pinfo, int offset) { static h248_trx_t* h248_trx(h248_msg_t* m ,guint32 t_id , h248_trx_type_t type) { h248_trx_t* t = NULL; h248_trx_msg_t* trxmsg; + + if ( !m ) return NULL; if (keep_persistent_data) { if (m->commited) { @@ -1419,6 +1421,8 @@ static h248_ctx_t* h248_ctx(h248_msg_t* m, h248_trx_t* t, guint32 c_id) { h248_ctx_t* context = NULL; h248_ctx_t** context_p = NULL; + if ( !m || !t ) return NULL; + if (keep_persistent_data) { if (m->commited) { gchar* key = ep_strdup_printf("%s:%.8x",m->addr_label,c_id); @@ -1452,6 +1456,7 @@ static h248_ctx_t* h248_ctx(h248_msg_t* m, h248_trx_t* t, guint32 c_id) { } } else { gchar* key = ep_strdup_printf("C%s:%.8x",m->addr_label,c_id); + if (( context = g_hash_table_lookup(ctxs_by_trx,t->key) )) { if (( context_p = g_hash_table_lookup(ctxs,key) )) { @@ -1514,6 +1519,8 @@ static h248_cmd_t* h248_cmd(h248_msg_t* m, h248_trx_t* t, h248_ctx_t* c, h248_cm h248_cmd_msg_t* cmdtrx; h248_cmd_msg_t* cmdctx; + if ( !m || !t || !c) return NULL; + if (keep_persistent_data) { if (m->commited) { DISSECTOR_ASSERT(t->cmds != NULL); @@ -1578,6 +1585,8 @@ static h248_cmd_t* h248_cmd(h248_msg_t* m, h248_trx_t* t, h248_ctx_t* c, h248_cm static void h248_cmd_add_term(h248_cmd_t* c, h248_term_t* t) { h248_terms_t* ct; + if ( !c ) return; + if (keep_persistent_data) { if ( c->msg->commited ) { return; @@ -1620,6 +1629,8 @@ static gchar* h248_cmd_to_str(h248_cmd_t* c) { gchar* s = "-"; h248_terms_t* term; + if ( !c ) return "-"; + switch (c->type) { case H248_CMD_NONE: return "-"; @@ -1701,6 +1712,9 @@ static gchar* h248_cmd_to_str(h248_cmd_t* c) { static gchar* h248_trx_to_str(h248_msg_t* m, h248_trx_t* t) { gchar* s = ep_strdup_printf("T %x { ",t->id); h248_cmd_msg_t* c; + + if ( !m || !t ) return "-"; + if (t->cmds) { if (t->cmds->cmd->ctx) { @@ -1726,6 +1740,8 @@ static gchar* h248_msg_to_str(h248_msg_t* m) { h248_trx_msg_t* t; gchar* s = ""; + if ( !m ) return "-"; + for (t = m->trxs; t; t = t->next) { s = ep_strdup_printf("%s %s",s,h248_trx_to_str(m,t->trx)); }; @@ -1746,6 +1762,7 @@ static void analyze_h248_msg(h248_msg_t* m) { h248_ctxs_t* ctx_node; h248_cmd_msg_t* c; + for (t = m->trxs; t; t = t->next) { for (c = t->trx->cmds; c; c = c->next) { h248_ctx_t* ctx = c->cmd->ctx; @@ -5425,7 +5442,7 @@ dissect_h248_MegacoMessage(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, /*--- End of included file: packet-h248-fn.c ---*/ -#line 1410 "packet-h248-template.c" +#line 1427 "packet-h248-template.c" static void dissect_h248(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) @@ -6619,7 +6636,7 @@ void proto_register_h248(void) { "", HFILL }}, /*--- End of included file: packet-h248-hfarr.c ---*/ -#line 1563 "packet-h248-template.c" +#line 1580 "packet-h248-template.c" { &hf_h248_ctx, { "Context", "h248.ctx", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }}, { &hf_h248_ctx_term, { "Termination", "h248.ctx.term", FT_STRING, BASE_NONE, NULL, 0, "", HFILL }}, @@ -6771,7 +6788,7 @@ void proto_register_h248(void) { &ett_h248_Value, /*--- End of included file: packet-h248-ettarr.c ---*/ -#line 1582 "packet-h248-template.c" +#line 1599 "packet-h248-template.c" }; module_t *h248_module; |