Wireshark-commits: [Wireshark-commits] master c1d6a41: Clean up reading code.
From: Wireshark code review <code-review-do-not-reply@xxxxxxxxxxxxx>
Date: Mon, 22 Sep 2014 10:48:58 +0000 (UTC)
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=c1d6a4123a2e100a77ae8ec2b3d01544f168febc
Submitter: Guy Harris (guy@xxxxxxxxxxxx)
Changed: branch: master
Repository: wireshark

Commits:

c1d6a41 by Guy Harris (guy@xxxxxxxxxxxx):

    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@xxxxxxxxxxxx>
    

Actions performed:

    from  a886f8f       packet-infiniband: added support for RoCE-v2 (RRocE)
    adds  c1d6a41   Clean up reading code.


Summary of changes:
 wiretap/pcapng.c |  159 +++++++++++++++++++++++++++---------------------------
 1 file changed, 78 insertions(+), 81 deletions(-)