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>
This commit is contained in:
Guy Harris 2016-04-18 18:18:12 -07:00
parent c943afbdac
commit b6784594f5
1 changed files with 15 additions and 2 deletions

View File

@ -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;
}