Use the packet length read from the packet header, and check for an EOF

and treat it as an error, when reading packets randomly.

svn path=/trunk/; revision=54517
This commit is contained in:
Guy Harris 2013-12-31 23:30:39 +00:00
parent 4648f411a7
commit 31d74c1922
1 changed files with 7 additions and 3 deletions

View File

@ -278,20 +278,24 @@ found:
static gboolean
aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
Buffer *buf, int length, int *err, gchar **err_info)
Buffer *buf, int length _U_, int *err, gchar **err_info)
{
struct aethrarec_hdr hdr;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, phdr, err, err_info))
if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, phdr, err,
err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
/*
* Read the packet data.
*/
if (!wtap_read_packet_bytes(wth->random_fh, buf, length, err, err_info))
if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info))
return FALSE; /* failed */
return TRUE;