Avoid abort on zero-length fields

Since commit v1.99.4rc0-70-g0bec885 (Remove use of sprintf for ftype
string formatting), Wireshark aborts with "Null pointer passed to
bytes_to_hexstr_punct()". This happened with a SSL capture where the
ssl.handshake.extensions_padding_data had a zero length.

Fix it by producing a zero-length string instead (as done by the
previous implementation).

Change-Id: I711d786a9ae692eb44c5e49a30d5fea41c5af31e
Reviewed-on: https://code.wireshark.org/review/7649
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Peter Wu 2015-03-12 01:47:02 +01:00 committed by Michael Mann
parent 0bec88518f
commit a9c75ca3c8
2 changed files with 4 additions and 2 deletions

View File

@ -158,7 +158,8 @@ bytes_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display, char *buf)
break;
}
buf = bytes_to_hexstr_punct(buf, fv->value.bytes->data, fv->value.bytes->len, separator);
if (fv->value.bytes->len)
buf = bytes_to_hexstr_punct(buf, fv->value.bytes->data, fv->value.bytes->len, separator);
*buf = '\0';
}

View File

@ -147,7 +147,8 @@ val_to_repr(fvalue_t *fv, ftrepr_t rtype, int field_display _U_, char * volatile
TRY {
length = tvb_length(fv->value.tvb);
buf = bytes_to_hexstr_punct(buf, tvb_get_ptr(fv->value.tvb, 0, length), length, ':');
if (length)
buf = bytes_to_hexstr_punct(buf, tvb_get_ptr(fv->value.tvb, 0, length), length, ':');
*buf = '\0';
}
CATCH_ALL {