to_str: Fixed incorrect order of checks in bytestring_to_str.

Issue revealed by commit 281dd22da9.
The commit that revealed the issue allowed bytestring_to_str to be
called when len was 0 and *ad was NULL causing a dissector bug to be reported.

Change-Id: I01c2c04154e0514dc2702b5c1c43ed5074d0ac11
Reviewed-on: https://code.wireshark.org/review/30421
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Martin Boye Petersen 2018-10-30 11:54:33 +01:00 committed by Peter Wu
parent 8f496ad4de
commit 1a2aa0e901
1 changed files with 4 additions and 4 deletions

View File

@ -188,14 +188,14 @@ bytestring_to_str(wmem_allocator_t *scope, const guint8 *ad, const guint32 len,
gchar *buf_ptr;
int truncated = 0;
if (!punct)
return bytes_to_str(scope, ad, len);
if (len == 0)
return wmem_strdup(scope, "");
if (!ad)
REPORT_DISSECTOR_BUG("Null pointer passed to bytestring_to_str()");
if (len == 0)
return wmem_strdup(scope, "");
if (!punct)
return bytes_to_str(scope, ad, len);
buf=(gchar *)wmem_alloc(scope, MAX_BYTE_STR_LEN+3+1);
if (buflen > MAX_BYTE_STR_LEN/3) { /* bd_len > 16 */