aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2015-04-30 19:19:35 +0200
committerPascal Quantin <pascal.quantin@gmail.com>2015-05-01 07:59:20 +0000
commitaa3870f54d2006237c63cad6e0245cab590b57b5 (patch)
treefd6798af2465e13a875a49dc03678ef214a34ed2 /epan
parentb84972635117aa5cac7f8e6296d07ceb51bfe5e2 (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>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-c1222.c14
1 files changed, 10 insertions, 4 deletions
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