diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-09-22 03:47:24 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-09-22 10:48:55 +0000 |
commit | c1d6a4123a2e100a77ae8ec2b3d01544f168febc (patch) | |
tree | 969a6e5207c67f46901c6d329f1c106c4d0c64b9 /wiretap/merge.c | |
parent | a886f8f740977234928eaa6db9c85471317ae9eb (diff) | |
download | wireshark-c1d6a4123a2e100a77ae8ec2b3d01544f168febc.tar.gz wireshark-c1d6a4123a2e100a77ae8ec2b3d01544f168febc.tar.bz2 wireshark-c1d6a4123a2e100a77ae8ec2b3d01544f168febc.zip |
Clean up reading code.
The only place where a short read should be treated as an EOF is if the
read of the block header reads 0 bytes. All other short reads,
including reads of the block header returning at least 1 byte but not
enough for a complete block header, and any reads of the stuff
*following* the block header even if they return 0 bytes, should be
treated as "short read" errors.
If the option length is bigger than the option buffer size, treat that
as a bad file (I'm not sure that can happen, so maybe it should be
treated as an internal error instead).
Use file_skip() rather than file_seek() when skipping forward N bytes.
If it fails, treat that as an error under all circumstances.
When reading the first section header block in the open routine, have
pcap_read_block() return -2 if it doesn't look like an SHB (too short,
wrong block type, bad block length, unknown byte-order magic number), as
that means the file isn't a pcap-ng file and the open should return 0.
Return -1, not 0, for all errors in various block-reading routines.
file_seek() returning 0 is *not* an error. file_seek() returning -1 (or
any other negative number *is* an error; its return value is signed, so
don't assign it to an unsigned variable.
This might fix the test errors for the Lua file format handler tests.
Change-Id: Ifa7d9834c38bf238461c9cc9625a2aa761cb6ff2
Reviewed-on: https://code.wireshark.org/review/4238
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/merge.c')
0 files changed, 0 insertions, 0 deletions