diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2015-04-30 19:19:35 +0200 |
---|---|---|
committer | Pascal Quantin <pascal.quantin@gmail.com> | 2015-05-01 07:59:20 +0000 |
commit | aa3870f54d2006237c63cad6e0245cab590b57b5 (patch) | |
tree | fd6798af2465e13a875a49dc03678ef214a34ed2 | |
parent | b84972635117aa5cac7f8e6296d07ceb51bfe5e2 (diff) |
C12.22: check c1222_baseoid_len before doing a memcpy
Should fix the following runtime error reported by Joerg:
../../asn1/c1222/packet-c1222-template.c:1427:3: runtime error: null pointer passed as argument 1, which is declared to never be null
../../asn1/c1222/packet-c1222-template.c:1427:3: runtime error: null pointer passed as argument 2, which is declared to never be null
Change-Id: I2f952815ed81e47b504e6479835a357b7656828e
Reviewed-on: https://code.wireshark.org/review/8251
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
-rw-r--r-- | asn1/c1222/packet-c1222-template.c | 14 | ||||
-rw-r--r-- | epan/dissectors/packet-c1222.c | 14 |
2 files changed, 20 insertions, 8 deletions
diff --git a/asn1/c1222/packet-c1222-template.c b/asn1/c1222/packet-c1222-template.c index 557f0e3adc..d9e4178f4d 100644 --- a/asn1/c1222/packet-c1222-template.c +++ b/asn1/c1222/packet-c1222-template.c @@ -1422,10 +1422,16 @@ proto_reg_handoff_c1222(void) dissector_add_uint("udp.port", global_c1222_port, c1222_udp_handle); initialized = TRUE; } - c1222_baseoid_len = oid_string2encoded(NULL, c1222_baseoid_str, &temp); - c1222_baseoid = (guint8 *)wmem_realloc(wmem_epan_scope(), c1222_baseoid, c1222_baseoid_len); - memcpy(c1222_baseoid, temp, c1222_baseoid_len); - wmem_free(NULL, temp); + if (c1222_baseoid_str && (c1222_baseoid_str[0] != '\0') && + ((c1222_baseoid_len = oid_string2encoded(NULL, c1222_baseoid_str, &temp)) != 0)) { + c1222_baseoid = (guint8 *)wmem_realloc(wmem_epan_scope(), c1222_baseoid, c1222_baseoid_len); + memcpy(c1222_baseoid, temp, c1222_baseoid_len); + wmem_free(NULL, temp); + } else if (c1222_baseoid) { + wmem_free(wmem_epan_scope(), c1222_baseoid); + c1222_baseoid = NULL; + c1222_baseoid_len = 0; + } } /* * Editor modelines - http://www.wireshark.org/tools/modelines.html diff --git a/epan/dissectors/packet-c1222.c b/epan/dissectors/packet-c1222.c index 404579645c..bc9b260bd2 100644 --- a/epan/dissectors/packet-c1222.c +++ b/epan/dissectors/packet-c1222.c @@ -2062,10 +2062,16 @@ proto_reg_handoff_c1222(void) dissector_add_uint("udp.port", global_c1222_port, c1222_udp_handle); initialized = TRUE; } - c1222_baseoid_len = oid_string2encoded(NULL, c1222_baseoid_str, &temp); - c1222_baseoid = (guint8 *)wmem_realloc(wmem_epan_scope(), c1222_baseoid, c1222_baseoid_len); - memcpy(c1222_baseoid, temp, c1222_baseoid_len); - wmem_free(NULL, temp); + if (c1222_baseoid_str && (c1222_baseoid_str[0] != '\0') && + ((c1222_baseoid_len = oid_string2encoded(NULL, c1222_baseoid_str, &temp)) != 0)) { + c1222_baseoid = (guint8 *)wmem_realloc(wmem_epan_scope(), c1222_baseoid, c1222_baseoid_len); + memcpy(c1222_baseoid, temp, c1222_baseoid_len); + wmem_free(NULL, temp); + } else if (c1222_baseoid) { + wmem_free(wmem_epan_scope(), c1222_baseoid); + c1222_baseoid = NULL; + c1222_baseoid_len = 0; + } } /* * Editor modelines - http://www.wireshark.org/tools/modelines.html |