diff options
-rw-r--r-- | wiretap/pcapng.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index e365da4158..263c17e901 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -1466,8 +1466,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t * * * Return the length of the name, including the terminating NUL. * - * If we don't find the terminating NUL, or if the name is zero-length - * (not counting the terminating NUL), return -1 and set *err and + * If we don't find a terminating NUL, return -1 and set *err and * *err_info appropriately. */ static int @@ -1493,12 +1492,6 @@ name_resolution_block_find_name_end(guint8 *p, guint record_len, int *err, record_len--; namelen++; /* count this byte */ } - if (namelen == 0) { - /* The name is empty. */ - *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup("pcapng_read_name_resolution_block: NRB record has empty host name"); - return -1; - } /* Include the NUL in the name length. */ return namelen + 1; @@ -1650,7 +1643,13 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t buffer_free(&nrb_rec); return -1; /* fail */ } - pn->add_new_ipv4(v4_addr, namep); + + /* + * Silently ignore zero-length + * names. + */ + if (namelen != 1) + pn->add_new_ipv4(v4_addr, namep); } } @@ -1714,8 +1713,15 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t buffer_free(&nrb_rec); return -1; /* fail */ } - pn->add_new_ipv6(buffer_start_ptr(&nrb_rec), - namep); + + /* + * Silently ignore zero-length + * names. + */ + if (namelen != 1) { + pn->add_new_ipv6(buffer_start_ptr(&nrb_rec), + namep); + } } } |