diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-04-18 18:18:12 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-04-19 01:19:21 +0000 |
commit | b6784594f5ed263462cc6d55fce403b53da61117 (patch) | |
tree | 8394d4223868f21af212d6f7cce174fea2fd2f0b /wiretap/mplog.c | |
parent | c943afbdacb2bfaa94500d2eb1705541bf3ebffb (diff) |
Detect and handle EOFs in the middle of a packet.
And *any* EOFs in the seek-read routine.
Change-Id: I5742c7bbd782e59e9c64e4821f22c706ddbc5382
Reviewed-on: https://code.wireshark.org/review/14995
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/mplog.c')
-rw-r--r-- | wiretap/mplog.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/wiretap/mplog.c b/wiretap/mplog.c index 87e5e7a587..c3041ff720 100644 --- a/wiretap/mplog.c +++ b/wiretap/mplog.c @@ -126,8 +126,15 @@ static gboolean mplog_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, p += ISO14443_PSEUDO_HDR_LEN; do { - if (!wtap_read_bytes_or_eof(fh, block, sizeof(block), err, err_info)) + if (!wtap_read_bytes_or_eof(fh, block, sizeof(block), err, err_info)) { + /* If we've already read some data, if this failed with an EOF, + so that *err is 0, it's a short read. */ + if (pkt_bytes != 0) { + if (*err == 0) + *err = WTAP_ERR_SHORT_READ; + } break; + } data = block[0]; type = block[1]; ctr = pletoh48(&block[2]); @@ -204,7 +211,13 @@ mplog_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *pkthdr, if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err)) return FALSE; - return mplog_read_packet(wth->random_fh, pkthdr, buf, err, err_info); + if (!mplog_read_packet(wth->random_fh, pkthdr, buf, err, err_info)) { + /* Even if we got an immediate EOF, that's an error. */ + if (*err == 0) + *err = WTAP_ERR_SHORT_READ; + return FALSE; + } + return TRUE; } |