From 32c38a4ecc7fc4f07349b0fbc13f7754be897546 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 20 Sep 2014 11:30:57 -0700 Subject: [PATCH] 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 --- wiretap/nettl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wiretap/nettl.c b/wiretap/nettl.c index 72cb1e22be..9fa6462fb7 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -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;