From de10bc6b5e23fee484c550cf71836f4368860699 Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Thu, 20 Jun 2013 23:37:16 +0000 Subject: [PATCH] Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8799 : Display certificate as UINT64 and add support for a 64bits unsigned value in BER dissector svn path=/trunk/; revision=50096 --- asn1/ocsp/ocsp.cnf | 5 +++++ epan/dissectors/packet-ber.c | 8 +++++--- epan/dissectors/packet-ocsp.c | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/asn1/ocsp/ocsp.cnf b/asn1/ocsp/ocsp.cnf index 134c7e2a32..3245d4be6b 100644 --- a/asn1/ocsp/ocsp.cnf +++ b/asn1/ocsp/ocsp.cnf @@ -3,6 +3,11 @@ # $Id$ +#.TYPE_ATTR +# pkix1explicit also exports the type CertificateSerialNumber. This makes sure asn2wrs uses the locally defined version. +CertificateSerialNumber TYPE = FT_UINT64 DISPLAY = BASE_DEC STRINGS = NULL BITMASK = 0 +#.END + #.MODULE_IMPORT PKIX1Implicit88 pkix1implicit PKIX1Explicit88 pkix1explicit diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index 3dd5d6580c..af8cd3b8ce 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -1664,6 +1664,7 @@ dissect_ber_integer64(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, gint64 val; guint32 i; gboolean used_too_many_bytes = FALSE; + guint8 first; #ifdef DEBUG_BER { const char *name; @@ -1695,8 +1696,10 @@ printf("INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d \n", name, im len = remaining>0 ? remaining : 0; } + first = tvb_get_guint8(tvb, offset); /* we can't handle integers > 64 bits */ - if (len > 8) { + /* take into account the use case of a 64bits unsigned integer: you will have a 9th byte set to 0 */ + if ((len > 9) || ((len == 9) && (first != 0))) { header_field_info *hfinfo; proto_item *pi = NULL; @@ -1718,7 +1721,6 @@ printf("INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d \n", name, im val=0; if (len > 0) { /* extend sign bit for signed fields */ - guint8 first = tvb_get_guint8(tvb, offset); enum ftenum type = FT_INT32; /* Default to signed, is this correct? */ if (hf_id >= 0) { type = proto_registrar_get_ftype(hf_id); @@ -1743,7 +1745,7 @@ printf("INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d \n", name, im if (hf_id >= 0) { /* */ - if ((len < 1) || (len > 8)) { + if ((len < 1) || (len > 9) || ((len == 9) && (first != 0))) { proto_item *pi = proto_tree_add_string_format( tree, hf_ber_error, tvb, offset-len, len, "invalid length", "BER Error: Can't handle integer length: %u", diff --git a/epan/dissectors/packet-ocsp.c b/epan/dissectors/packet-ocsp.c index ead8860f08..a576adaf1f 100644 --- a/epan/dissectors/packet-ocsp.c +++ b/epan/dissectors/packet-ocsp.c @@ -319,7 +319,7 @@ dissect_ocsp_T_responseType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of static int dissect_ocsp_T_response(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 38 "../../asn1/ocsp/ocsp.cnf" +#line 43 "../../asn1/ocsp/ocsp.cnf" gint8 appclass; gboolean pc, ind; gint32 tag; @@ -794,7 +794,7 @@ void proto_register_ocsp(void) { "OCTET_STRING", HFILL }}, { &hf_ocsp_serialNumber, { "serialNumber", "ocsp.serialNumber", - FT_INT32, BASE_DEC, NULL, 0, + FT_UINT64, BASE_DEC, NULL, 0, "CertificateSerialNumber", HFILL }}, { &hf_ocsp_responseStatus, { "responseStatus", "ocsp.responseStatus",