From 7de6b0822ad764edfa0ddd76e6a383bd3408a4e6 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 8 Apr 2021 19:38:26 -0700 Subject: [PATCH] pcapng: expand a comment and tweak the version test. Drop in the comment from libpcap about version 1.2 (I wrote that comment, and generously double-license it under the BSD license and the GPL :-)). Redo the version test as if (!({version is one we handle})) to match the way it's done in libpcap. --- wiretap/pcapng.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index fb53f050b5..5d6e97fc0d 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -772,8 +772,22 @@ pcapng_read_section_header_block(FILE_T fh, pcapng_block_header_t *bh, return PCAPNG_BLOCK_ERROR; } - /* we currently only understand SHB V1.0 SHB V1.2*/ - if (version_major != 1 || version_minor == 1 || version_minor > 2) { + /* Currently only SHB versions 1.0 and 1.2 are supported; + version 1.2 is treated as being the same as version 1.0. + See the current version of the pcapng specification. + + Version 1.2 is written by some programs that write additional + block types (which can be read by any code that handles them, + regarless of whether the minor version if 0 or 2, so that's + not a reason to change the minor version number). + + XXX - the pcapng specification says that readers should + just ignore sections with an unsupported version number; + presumably they can also report an error if they skip + all the way to the end of the file without finding + any versions that they support. */ + if (!(version_major == 1 && + (version_minor == 0 || version_minor == 2))) { *err = WTAP_ERR_UNSUPPORTED; *err_info = g_strdup_printf("pcapng_read_section_header_block: unknown SHB version %u.%u", version_major, version_minor);