Add file_error() calls after file_read().

If file_read() doesn't return the exact number of bytes you asked for,
and you really need all those bytes to be there, you have to call
file_error() to find out what the problem is.

Change-Id: I4cc87bc1b6cc5a49bbcbf93b56106f57af290d20
Reviewed-on: https://code.wireshark.org/review/4205
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-09-20 11:30:57 -07:00
parent 2cd9784f10
commit 32c38a4ecc
1 changed files with 3 additions and 0 deletions

View File

@ -235,6 +235,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
/* read the first header to take a guess at the file encap */
bytes_read = file_read(dummy, 4, wth->fh);
if (bytes_read != 4) {
*err = file_error(wth->fh, err_info);
if (*err != 0) {
return -1;
}
@ -625,6 +626,7 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
bytes_to_read = datalen;
bytes_read = file_read(pd, bytes_to_read, fh);
if (bytes_read != bytes_to_read) {
*err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
@ -641,6 +643,7 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
bytes_to_read = datalen;
bytes_read = file_read(dummy, bytes_to_read, fh);
if (bytes_read != bytes_to_read) {
*err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;