From 3c5541906b71736ecfcc6d89b31195d7c8e5d383 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 20 Sep 2014 10:45:28 -0700 Subject: [PATCH] Set err_info if the attempts to read record headers fail. If it fails due to, for example, the file being gzipped and having a bad gzip CRC, the error returned is WTAP_ERR_DECOMPRESS and, for that error, err_info is expected to be set to a string giving details of the problem, so we need to pass back to our caller the string in question. Bug: 10484 Change-Id: I3aa2a92d04fcc08946ff073a40efa708079bbb3e Reviewed-on: https://code.wireshark.org/review/4201 Reviewed-by: Guy Harris --- wiretap/libpcap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index 11fb7730c2..75e52015fd 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -56,7 +56,7 @@ typedef struct { #endif /* Try to read the first two records of the capture file. */ -static int libpcap_try(wtap *wth, int *err); +static int libpcap_try(wtap *wth, int *err, gchar **err_info); static int libpcap_try_header(wtap *wth, FILE_T fh, int *err, gchar **err_info, struct pcaprec_ss990915_hdr *hdr); @@ -394,7 +394,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info) first_packet_offset = file_tell(wth->fh); for (i = 0; i < n_subtypes; i++) { wth->file_type_subtype = subtypes[i]; - figures_of_merit[i] = libpcap_try(wth, err); + figures_of_merit[i] = libpcap_try(wth, err, err_info); if (figures_of_merit[i] == -1) { /* * Well, we couldn't even read it. @@ -464,7 +464,7 @@ done: } /* Try to read the first two records of the capture file. */ -static int libpcap_try(wtap *wth, int *err) +static int libpcap_try(wtap *wth, int *err, gchar **err_info) { int ret; @@ -477,7 +477,7 @@ static int libpcap_try(wtap *wth, int *err) /* * Attempt to read the first record's header. */ - ret = libpcap_try_header(wth, wth->fh, err, NULL, &first_rec_hdr); + ret = libpcap_try_header(wth, wth->fh, err, err_info, &first_rec_hdr); if (ret == -1) { if (*err == 0 || *err == WTAP_ERR_SHORT_READ) { /* @@ -510,7 +510,7 @@ static int libpcap_try(wtap *wth, int *err) /* * Now attempt to read the second record's header. */ - ret = libpcap_try_header(wth, wth->fh, err, NULL, &second_rec_hdr); + ret = libpcap_try_header(wth, wth->fh, err, err_info, &second_rec_hdr); if (ret == -1) { if (*err == 0 || *err == WTAP_ERR_SHORT_READ) { /*