Add a new WTAP_ERR_DECOMPRESS error, and use that for errors discovered

by the gunzipping code.  Have it also supply a err_info string, and
report it.  Have file_error() supply an err_info string.

Put "the file" - or, for WTAP_ERR_DECOMPRESS, "the compressed file", to
suggest a decompression error - into the rawshark and tshark errors,
along the lines of what other programs print.

Fix a case in the Netscaler code where we weren't fetching the error
code on a read failure.


git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36748 f5534014-38df-0310-8fa8-9805f1628bb7
This commit is contained in:
guy 2011-04-21 09:41:52 +00:00
parent bf80a1d2d0
commit bf5d8d18e3
51 changed files with 717 additions and 557 deletions

View File

@ -637,6 +637,7 @@ process_cap_file(wtap *wth, const char *filename)
case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNSUPPORTED:
case WTAP_ERR_UNSUPPORTED_ENCAP: case WTAP_ERR_UNSUPPORTED_ENCAP:
case WTAP_ERR_BAD_RECORD: case WTAP_ERR_BAD_RECORD:
case WTAP_ERR_DECOMPRESS:
fprintf(stderr, "(%s)\n", err_info); fprintf(stderr, "(%s)\n", err_info);
g_free(err_info); g_free(err_info);
break; break;

View File

@ -185,6 +185,14 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
errmsg = "A full header couldn't be written to the file \"%s\"."; errmsg = "A full header couldn't be written to the file \"%s\".";
break; break;
case WTAP_ERR_DECOMPRESS:
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The compressed file \"%%s\" appears to be damaged or corrupt.\n"
"(%s)", err_info);
g_free(err_info);
errmsg = errmsg_errno;
break;
default: default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno), g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The file \"%%s\" could not be %s: %s.", "The file \"%%s\" could not be %s: %s.",

23
file.c
View File

@ -742,6 +742,14 @@ cf_read(capture_file *cf, gboolean from_save)
errmsg = errmsg_errno; errmsg = errmsg_errno;
break; break;
case WTAP_ERR_DECOMPRESS:
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The compressed capture file appears to be damaged or corrupt.\n"
"(%s)", err_info);
g_free(err_info);
errmsg = errmsg_errno;
break;
default: default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno), g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"An error occurred while reading the" "An error occurred while reading the"
@ -1448,6 +1456,14 @@ cf_merge_files(char **out_filenamep, int in_file_count,
errmsg = errmsg_errno; errmsg = errmsg_errno;
break; break;
case WTAP_ERR_DECOMPRESS:
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The compressed capture file %%s appears to be damaged or corrupt.\n"
"(%s)", err_info);
g_free(err_info);
errmsg = errmsg_errno;
break;
default: default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno), g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"An error occurred while reading the" "An error occurred while reading the"
@ -3910,6 +3926,13 @@ cf_open_failure_alert_box(const char *filename, int err, gchar *err_info,
"Gzip compression not supported by this file type."); "Gzip compression not supported by this file type.");
break; break;
case WTAP_ERR_DECOMPRESS:
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"The compressed file \"%s\" appears to be damaged or corrupt.\n"
"(%s)", filename, err_info);
g_free(err_info);
break;
default: default:
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"The file \"%s\" could not be %s: %s.", "The file \"%s\" could not be %s: %s.",

View File

@ -990,27 +990,32 @@ load_cap_file(capture_file *cf)
switch (err) { switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP: case WTAP_ERR_UNSUPPORTED_ENCAP:
cmdarg_err("\"%s\" has a packet with a network type that Rawshark doesn't support.\n(%s)", cmdarg_err("The file \"%s\" has a packet with a network type that Rawshark doesn't support.\n(%s)",
cf->filename, err_info); cf->filename, err_info);
break; break;
case WTAP_ERR_CANT_READ: case WTAP_ERR_CANT_READ:
cmdarg_err("An attempt to read from \"%s\" failed for some unknown reason.", cmdarg_err("An attempt to read from the file \"%s\" failed for some unknown reason.",
cf->filename); cf->filename);
break; break;
case WTAP_ERR_SHORT_READ: case WTAP_ERR_SHORT_READ:
cmdarg_err("\"%s\" appears to have been cut short in the middle of a packet.", cmdarg_err("The file \"%s\" appears to have been cut short in the middle of a packet.",
cf->filename); cf->filename);
break; break;
case WTAP_ERR_BAD_RECORD: case WTAP_ERR_BAD_RECORD:
cmdarg_err("\"%s\" appears to be damaged or corrupt.\n(%s)", cmdarg_err("The file \"%s\" appears to be damaged or corrupt.\n(%s)",
cf->filename, err_info);
break;
case WTAP_ERR_DECOMPRESS:
cmdarg_err("The compressed file \"%s\" appears to be damaged or corrupt.\n(%s)",
cf->filename, err_info); cf->filename, err_info);
break; break;
default: default:
cmdarg_err("An error occurred while reading \"%s\": %s.", cmdarg_err("An error occurred while reading the file \"%s\": %s.",
cf->filename, wtap_strerror(err)); cf->filename, wtap_strerror(err));
break; break;
} }

View File

@ -2766,29 +2766,34 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
switch (err) { switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP: case WTAP_ERR_UNSUPPORTED_ENCAP:
cmdarg_err("\"%s\" has a packet with a network type that TShark doesn't support.\n(%s)", cmdarg_err("The file \"%s\" has a packet with a network type that TShark doesn't support.\n(%s)",
cf->filename, err_info); cf->filename, err_info);
g_free(err_info); g_free(err_info);
break; break;
case WTAP_ERR_CANT_READ: case WTAP_ERR_CANT_READ:
cmdarg_err("An attempt to read from \"%s\" failed for some unknown reason.", cmdarg_err("An attempt to read from the file \"%s\" failed for some unknown reason.",
cf->filename); cf->filename);
break; break;
case WTAP_ERR_SHORT_READ: case WTAP_ERR_SHORT_READ:
cmdarg_err("\"%s\" appears to have been cut short in the middle of a packet.", cmdarg_err("The file \"%s\" appears to have been cut short in the middle of a packet.",
cf->filename); cf->filename);
break; break;
case WTAP_ERR_BAD_RECORD: case WTAP_ERR_BAD_RECORD:
cmdarg_err("\"%s\" appears to be damaged or corrupt.\n(%s)", cmdarg_err("The file \"%s\" appears to be damaged or corrupt.\n(%s)",
cf->filename, err_info); cf->filename, err_info);
g_free(err_info); g_free(err_info);
break; break;
case WTAP_ERR_DECOMPRESS:
cmdarg_err("The compressed file \"%s\" appears to be damaged or corrupt.\n"
"(%s)", cf->filename, err_info);
break;
default: default:
cmdarg_err("An error occurred while reading \"%s\": %s.", cmdarg_err("An error occurred while reading the file \"%s\": %s.",
cf->filename, wtap_strerror(err)); cf->filename, wtap_strerror(err));
break; break;
} }
@ -3532,6 +3537,15 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
errmsg = "A full header couldn't be written to the file \"%s\"."; errmsg = "A full header couldn't be written to the file \"%s\".";
break; break;
case WTAP_ERR_DECOMPRESS:
/* Seen only when opening a capture file for reading. */
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The compressed file \"%%s\" appears to be damaged or corrupt.\n"
"(%s)", err_info);
g_free(err_info);
errmsg = errmsg_errno;
break;
default: default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno), g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The file \"%%s\" could not be %s: %s.", "The file \"%%s\" could not be %s: %s.",

View File

@ -106,9 +106,9 @@ typedef struct
static gboolean _5views_read(wtap *wth, int *err, gchar **err_info, static gboolean _5views_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset); gint64 *data_offset);
static gboolean _5views_read_rec_data(FILE_T fh, guchar *pd, int length, static gboolean _5views_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err); int *err, gchar **err_info);
static int _5views_read_header(wtap *wth, FILE_T fh, static int _5views_read_header(wtap *wth, FILE_T fh,
t_5VW_TimeStamped_Header *hdr, int *err); t_5VW_TimeStamped_Header *hdr, int *err, gchar **err_info);
static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, static gboolean _5views_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info); int *err, gchar **err_info);
@ -128,7 +128,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&Capture_Header.Info_Header, sizeof(t_5VW_Info_Header), wth->fh); bytes_read = file_read(&Capture_Header.Info_Header, sizeof(t_5VW_Info_Header), wth->fh);
if (bytes_read != sizeof(t_5VW_Info_Header)) { if (bytes_read != sizeof(t_5VW_Info_Header)) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -184,7 +184,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
/* read the remaining header information */ /* read the remaining header information */
bytes_read = file_read(&Capture_Header.HeaderDateCreation, sizeof (t_5VW_Capture_Header) - sizeof(t_5VW_Info_Header), wth->fh); bytes_read = file_read(&Capture_Header.HeaderDateCreation, sizeof (t_5VW_Capture_Header) - sizeof(t_5VW_Info_Header), wth->fh);
if (bytes_read != sizeof (t_5VW_Capture_Header)- sizeof(t_5VW_Info_Header) ) { if (bytes_read != sizeof (t_5VW_Capture_Header)- sizeof(t_5VW_Info_Header) ) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -204,7 +204,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
/* Read the next packet */ /* Read the next packet */
static gboolean static gboolean
_5views_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{ {
t_5VW_TimeStamped_Header TimeStamped_Header; t_5VW_TimeStamped_Header TimeStamped_Header;
int bytes_read; int bytes_read;
@ -213,7 +213,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset)
do do
{ {
bytes_read = _5views_read_header(wth, wth->fh, &TimeStamped_Header, err); bytes_read = _5views_read_header(wth, wth->fh, &TimeStamped_Header, err, err_info);
if (bytes_read == -1) { if (bytes_read == -1) {
/* /*
* We failed to read the header. * We failed to read the header.
@ -245,7 +245,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset)
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
if (!_5views_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), if (!_5views_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
packet_size, err)) packet_size, err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -271,7 +271,8 @@ _5views_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset)
static gboolean static gboolean
_5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) _5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -279,7 +280,7 @@ _5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
bytes_read = file_read(pd, length, fh); bytes_read = file_read(pd, length, fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -294,7 +295,7 @@ _5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
Return -1 on an error, or the number of bytes of header read on success. */ Return -1 on an error, or the number of bytes of header read on success. */
static int static int
_5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr, int *err) _5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr, int *err, gchar **err_info)
{ {
int bytes_read, bytes_to_read; int bytes_read, bytes_to_read;
@ -303,7 +304,7 @@ _5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
/* Read record header. */ /* Read record header. */
bytes_read = file_read(hdr, bytes_to_read, fh); bytes_read = file_read(hdr, bytes_to_read, fh);
if (bytes_read != bytes_to_read) { if (bytes_read != bytes_to_read) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0 && bytes_read != 0) { if (*err == 0 && bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -316,14 +317,14 @@ _5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
static gboolean static gboolean
_5views_seek_read(wtap *wth, gint64 seek_off, _5views_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE; return FALSE;
/* /*
* Read the packet data. * Read the packet data.
*/ */
if (!_5views_read_rec_data(wth->random_fh, pd, length, err)) if (!_5views_read_rec_data(wth->random_fh, pd, length, err, err_info))
return FALSE; return FALSE;
switch (wth->file_encap) { switch (wth->file_encap) {

View File

@ -94,7 +94,8 @@ static gboolean airopeekv9_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info); int *err, gchar **err_info);
static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err) static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err,
gchar **err_info)
{ {
int c; int c;
const char *cp; const char *cp;
@ -107,7 +108,7 @@ static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err)
if (file_eof(wth->fh)) if (file_eof(wth->fh))
return 0; /* EOF */ return 0; /* EOF */
else { else {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return -1; /* error */ return -1; /* error */
} }
} }
@ -126,7 +127,8 @@ static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err)
static int wtap_file_read_till_separator (wtap *wth, char *buffer, int buflen, static int wtap_file_read_till_separator (wtap *wth, char *buffer, int buflen,
const char *separators, int *err) const char *separators, int *err,
gchar **err_info)
{ {
int c; int c;
char *cp; char *cp;
@ -139,7 +141,7 @@ static int wtap_file_read_till_separator (wtap *wth, char *buffer, int buflen,
if (file_eof(wth->fh)) if (file_eof(wth->fh))
return 0; /* EOF */ return 0; /* EOF */
else { else {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return -1; /* error */ return -1; /* error */
} }
} }
@ -155,7 +157,8 @@ static int wtap_file_read_till_separator (wtap *wth, char *buffer, int buflen,
} }
static int wtap_file_read_number (wtap *wth, guint32 *num, int *err) static int wtap_file_read_number (wtap *wth, guint32 *num, int *err,
gchar **err_info)
{ {
int ret; int ret;
char str_num[12]; char str_num[12];
@ -163,7 +166,7 @@ static int wtap_file_read_number (wtap *wth, guint32 *num, int *err)
char *p; char *p;
ret = wtap_file_read_till_separator (wth, str_num, sizeof (str_num)-1, "<", ret = wtap_file_read_till_separator (wth, str_num, sizeof (str_num)-1, "<",
err); err, err_info);
if (ret != 1) { if (ret != 1) {
/* 0 means EOF, which means "not a valid AiroPeek V9 file"; /* 0 means EOF, which means "not a valid AiroPeek V9 file";
-1 means error, and "err" has been set. */ -1 means error, and "err" has been set. */
@ -194,7 +197,8 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info)
#define NUM_AIROPEEK9_ENCAPS (sizeof airopeek9_encap / sizeof airopeek9_encap[0]) #define NUM_AIROPEEK9_ENCAPS (sizeof airopeek9_encap / sizeof airopeek9_encap[0])
airopeek9_t *airopeek9; airopeek9_t *airopeek9;
wtap_file_read_unknown_bytes(&ap_hdr, sizeof(ap_hdr), wth->fh, err); wtap_file_read_unknown_bytes(&ap_hdr, sizeof(ap_hdr), wth->fh, err,
err_info);
if (memcmp (ap_hdr.section_id, "\177ver", sizeof(ap_hdr.section_id)) != 0) if (memcmp (ap_hdr.section_id, "\177ver", sizeof(ap_hdr.section_id)) != 0)
return 0; /* doesn't begin with a "\177ver" section */ return 0; /* doesn't begin with a "\177ver" section */
@ -207,13 +211,13 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info)
* we have the file version (and possibly check to make sure all * we have the file version (and possibly check to make sure all
* tags are properly opened and closed). * tags are properly opened and closed).
*/ */
ret = wtap_file_read_pattern (wth, "<FileVersion>", err); ret = wtap_file_read_pattern (wth, "<FileVersion>", err, err_info);
if (ret != 1) { if (ret != 1) {
/* 0 means EOF, which means "not a valid AiroPeek V9 file"; /* 0 means EOF, which means "not a valid AiroPeek V9 file";
-1 means error, and "err" has been set. */ -1 means error, and "err" has been set. */
return ret; return ret;
} }
ret = wtap_file_read_number (wth, &fileVersion, err); ret = wtap_file_read_number (wth, &fileVersion, err, err_info);
if (ret != 1) { if (ret != 1) {
/* 0 means EOF, which means "not a valid AiroPeek V9 file"; /* 0 means EOF, which means "not a valid AiroPeek V9 file";
-1 means error, and "err" has been set. */ -1 means error, and "err" has been set. */
@ -239,7 +243,7 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info)
* we have the file version (and possibly check to make sure all * we have the file version (and possibly check to make sure all
* tags are properly opened and closed). * tags are properly opened and closed).
*/ */
ret = wtap_file_read_pattern (wth, "<MediaType>", err); ret = wtap_file_read_pattern (wth, "<MediaType>", err, err_info);
if (ret == -1) if (ret == -1)
return -1; return -1;
if (ret == 0) { if (ret == 0) {
@ -249,7 +253,7 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info)
} }
/* XXX - this appears to be 0 in both the EtherPeek and AiroPeek /* XXX - this appears to be 0 in both the EtherPeek and AiroPeek
files we've seen; should we require it to be 0? */ files we've seen; should we require it to be 0? */
ret = wtap_file_read_number (wth, &mediaType, err); ret = wtap_file_read_number (wth, &mediaType, err, err_info);
if (ret == -1) if (ret == -1)
return -1; return -1;
if (ret == 0) { if (ret == 0) {
@ -258,7 +262,7 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info)
return -1; return -1;
} }
ret = wtap_file_read_pattern (wth, "<MediaSubType>", err); ret = wtap_file_read_pattern (wth, "<MediaSubType>", err, err_info);
if (ret == -1) if (ret == -1)
return -1; return -1;
if (ret == 0) { if (ret == 0) {
@ -266,7 +270,7 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info)
*err_info = g_strdup("airopeekv9: <MediaSubType> tag not found"); *err_info = g_strdup("airopeekv9: <MediaSubType> tag not found");
return -1; return -1;
} }
ret = wtap_file_read_number (wth, &mediaSubType, err); ret = wtap_file_read_number (wth, &mediaSubType, err, err_info);
if (ret == -1) if (ret == -1)
return -1; return -1;
if (ret == 0) { if (ret == 0) {
@ -282,7 +286,7 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info)
return -1; return -1;
} }
ret = wtap_file_read_pattern (wth, "pkts", err); ret = wtap_file_read_pattern (wth, "pkts", err, err_info);
if (ret == -1) if (ret == -1)
return -1; return -1;
if (ret == 0) { if (ret == 0) {
@ -361,7 +365,7 @@ airopeekv9_process_header(FILE_T fh, hdr_info_t *hdr_info, int *err,
XXX - this assumes all values are 4 bytes long. */ XXX - this assumes all values are 4 bytes long. */
bytes_read = file_read(tag_value, sizeof tag_value, fh); bytes_read = file_read(tag_value, sizeof tag_value, fh);
if (bytes_read != (int) sizeof tag_value) { if (bytes_read != (int) sizeof tag_value) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
if (bytes_read > 0) if (bytes_read > 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -508,7 +512,8 @@ static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info,
/* read the frame data */ /* read the frame data */
buffer_assure_space(wth->frame_buffer, hdr_info.sliceLength); buffer_assure_space(wth->frame_buffer, hdr_info.sliceLength);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer), wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
hdr_info.sliceLength, wth->fh, err); hdr_info.sliceLength, wth->fh, err,
err_info);
wth->data_offset += hdr_info.sliceLength; wth->data_offset += hdr_info.sliceLength;
/* recalculate and fill in packet time stamp */ /* recalculate and fill in packet time stamp */
@ -591,6 +596,6 @@ airopeekv9_seek_read(wtap *wth, gint64 seek_off,
* XXX - should "errno" be set in "wtap_file_read_expected_bytes()"? * XXX - should "errno" be set in "wtap_file_read_expected_bytes()"?
*/ */
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
wtap_file_read_expected_bytes(pd, length, wth->random_fh, err); wtap_file_read_expected_bytes(pd, length, wth->random_fh, err, err_info);
return TRUE; return TRUE;
} }

View File

@ -93,7 +93,7 @@ static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
/* Seeks to the beginning of the next packet, and returns the /* Seeks to the beginning of the next packet, and returns the
byte offset at which the header for that packet begins. byte offset at which the header for that packet begins.
Returns -1 on failure. */ Returns -1 on failure. */
static gint64 ascend_seek(wtap *wth, int *err) static gint64 ascend_seek(wtap *wth, int *err, gchar **err_info)
{ {
int byte; int byte;
gint64 date_off = -1, cur_off, packet_off; gint64 date_off = -1, cur_off, packet_off;
@ -121,7 +121,7 @@ static gint64 ascend_seek(wtap *wth, int *err)
cur_off = file_tell(wth->fh); cur_off = file_tell(wth->fh);
if (cur_off == -1) { if (cur_off == -1) {
/* Error. */ /* Error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return -1; return -1;
} }
@ -156,7 +156,7 @@ static gint64 ascend_seek(wtap *wth, int *err)
} else { } else {
/* We (presumably) got an error (there's no equivalent to "ferror()" /* We (presumably) got an error (there's no equivalent to "ferror()"
in zlib, alas, so we don't have a wrapper to check for an error). */ in zlib, alas, so we don't have a wrapper to check for an error). */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
} }
return -1; return -1;
@ -173,7 +173,7 @@ found:
return packet_off; return packet_off;
} }
int ascend_open(wtap *wth, int *err, gchar **err_info _U_) int ascend_open(wtap *wth, int *err, gchar **err_info)
{ {
gint64 offset; gint64 offset;
struct stat statbuf; struct stat statbuf;
@ -187,7 +187,7 @@ int ascend_open(wtap *wth, int *err, gchar **err_info _U_)
fill it in. */ fill it in. */
wth->priv = NULL; wth->priv = NULL;
offset = ascend_seek(wth, err); offset = ascend_seek(wth, err, err_info);
if (offset == -1) { if (offset == -1) {
if (*err == 0) if (*err == 0)
return 0; return 0;
@ -285,7 +285,7 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
SEEK_SET, err) == -1) SEEK_SET, err) == -1)
return FALSE; return FALSE;
offset = ascend_seek(wth, err); offset = ascend_seek(wth, err, err_info);
if (offset == -1) if (offset == -1)
return FALSE; return FALSE;
if (parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header, if (parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header,

View File

@ -75,7 +75,7 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
buf = buffer_start_ptr(wth->frame_buffer); buf = buffer_start_ptr(wth->frame_buffer);
wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err); wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info);
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -94,7 +94,7 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
} }
static gboolean ber_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header _U_, static gboolean ber_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header _U_,
guint8 *pd, int length, int *err, gchar **err_info _U_) guint8 *pd, int length, int *err, gchar **err_info)
{ {
int packet_size = length; int packet_size = length;
@ -107,12 +107,12 @@ static gboolean ber_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_head
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE; return FALSE;
wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err); wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err, err_info);
return TRUE; return TRUE;
} }
int ber_open(wtap *wth, int *err, gchar **err_info _U_) int ber_open(wtap *wth, int *err, gchar **err_info)
{ {
#define BER_BYTES_TO_CHECK 8 #define BER_BYTES_TO_CHECK 8
guint8 bytes[BER_BYTES_TO_CHECK]; guint8 bytes[BER_BYTES_TO_CHECK];
@ -128,7 +128,7 @@ int ber_open(wtap *wth, int *err, gchar **err_info _U_)
bytes_read = file_read(&bytes, BER_BYTES_TO_CHECK, wth->fh); bytes_read = file_read(&bytes, BER_BYTES_TO_CHECK, wth->fh);
if (bytes_read != BER_BYTES_TO_CHECK) { if (bytes_read != BER_BYTES_TO_CHECK) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return (*err != 0) ? -1 : 0; return (*err != 0) ? -1 : 0;
} }

View File

@ -78,9 +78,10 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off, static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info); int *err, gchar **err_info);
static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err); static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info);
int btsnoop_open(wtap *wth, int *err, gchar **err_info _U_) int btsnoop_open(wtap *wth, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
char magic[sizeof btsnoop_magic]; char magic[sizeof btsnoop_magic];
@ -92,7 +93,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info _U_)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, sizeof magic, wth->fh); bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) { if (bytes_read != sizeof magic) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -107,7 +108,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info _U_)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, wth->fh); bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) { if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -174,7 +175,7 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, wth->fh); bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) { if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -197,7 +198,7 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
if (!snoop_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), if (!snoop_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
packet_size, err)) { packet_size, err, err_info)) {
return FALSE; /* Read error */ return FALSE; /* Read error */
} }
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -237,7 +238,7 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off, static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info _U_) { int *err, gchar **err_info) {
int bytes_read; int bytes_read;
struct btsnooprec_hdr hdr; struct btsnooprec_hdr hdr;
guint32 flags; guint32 flags;
@ -248,7 +249,7 @@ static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, wth->random_fh); bytes_read = file_read(&hdr, sizeof hdr, wth->random_fh);
if (bytes_read != sizeof hdr) { if (bytes_read != sizeof hdr) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -258,7 +259,7 @@ static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
/* /*
* Read the packet data. * Read the packet data.
*/ */
if (!snoop_read_rec_data(wth->random_fh, pd, length, err)) if (!snoop_read_rec_data(wth->random_fh, pd, length, err, err_info))
return FALSE; /* failed */ return FALSE; /* failed */
if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR) if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR)
@ -288,7 +289,8 @@ static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
} }
static gboolean static gboolean
snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -296,7 +298,7 @@ snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
bytes_read = file_read(pd, length, fh); bytes_read = file_read(pd, length, fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -82,23 +82,23 @@ typedef struct commview_header {
#define MEDIUM_WIFI 1 #define MEDIUM_WIFI 1
#define MEDIUM_TOKEN_RING 2 #define MEDIUM_TOKEN_RING 2
static gboolean commview_read(wtap *wth, int *err, gchar **err_info _U_, static gboolean commview_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset); gint64 *data_offset);
static gboolean commview_seek_read(wtap *wth, gint64 seek_off, static gboolean commview_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, union wtap_pseudo_header *pseudo_header,
guchar *pd, int length, int *err, guchar *pd, int length, int *err,
gchar **err_info _U_); gchar **err_info);
static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh, static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh,
int *err); int *err, gchar **err_info);
static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header _U_, const union wtap_pseudo_header *pseudo_header _U_,
const guchar *pd, int *err); const guchar *pd, int *err);
int commview_open(wtap *wth, int *err, gchar **err_info _U_) int commview_open(wtap *wth, int *err, gchar **err_info)
{ {
commview_header_t cv_hdr; commview_header_t cv_hdr;
if(!commview_read_header(&cv_hdr, wth->fh, err)) if(!commview_read_header(&cv_hdr, wth->fh, err, err_info))
return -1; return -1;
/* If any of these fields do not match what we expect, bail out. */ /* If any of these fields do not match what we expect, bail out. */
@ -133,7 +133,7 @@ int commview_open(wtap *wth, int *err, gchar **err_info _U_)
} }
static gboolean static gboolean
commview_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{ {
commview_header_t cv_hdr; commview_header_t cv_hdr;
struct tm tm; struct tm tm;
@ -141,7 +141,7 @@ commview_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset)
*data_offset = wth->data_offset; *data_offset = wth->data_offset;
if(!commview_read_header(&cv_hdr, wth->fh, err)) if(!commview_read_header(&cv_hdr, wth->fh, err, err_info))
return FALSE; return FALSE;
wth->data_offset += COMMVIEW_HEADER_SIZE; wth->data_offset += COMMVIEW_HEADER_SIZE;
@ -170,7 +170,7 @@ commview_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset)
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), bytes_read = file_read(buffer_start_ptr(wth->frame_buffer),
cv_hdr.data_len, wth->fh); cv_hdr.data_len, wth->fh);
if(bytes_read != cv_hdr.data_len) { if(bytes_read != cv_hdr.data_len) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if(*err == 0) if(*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -198,7 +198,7 @@ commview_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset)
static gboolean static gboolean
commview_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header commview_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
*pseudo_header, guchar *pd, int length, int *err, *pseudo_header, guchar *pd, int length, int *err,
gchar **err_info _U_) gchar **err_info)
{ {
commview_header_t cv_hdr; commview_header_t cv_hdr;
int bytes_read; int bytes_read;
@ -206,7 +206,7 @@ commview_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE; return FALSE;
if(!commview_read_header(&cv_hdr, wth->random_fh, err)) { if(!commview_read_header(&cv_hdr, wth->random_fh, err, err_info)) {
if(*err == 0) if(*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -229,7 +229,7 @@ commview_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
bytes_read = file_read(pd, cv_hdr.data_len, wth->random_fh); bytes_read = file_read(pd, cv_hdr.data_len, wth->random_fh);
if(bytes_read != cv_hdr.data_len) { if(bytes_read != cv_hdr.data_len) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
if(*err == 0) if(*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -240,7 +240,8 @@ commview_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
} }
static gboolean static gboolean
commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err) commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err,
gchar **err_info)
{ {
int bytes_read = 0; int bytes_read = 0;
@ -270,7 +271,7 @@ commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err)
cv_hdr->usecs = GUINT32_FROM_LE(cv_hdr->usecs); cv_hdr->usecs = GUINT32_FROM_LE(cv_hdr->usecs);
if(bytes_read < COMMVIEW_HEADER_SIZE) { if(bytes_read < COMMVIEW_HEADER_SIZE) {
*err = file_error(fh); *err = file_error(fh, err_info);
if(*err == 0 && bytes_read > 0) if(*err == 0 && bytes_read > 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;

View File

@ -167,8 +167,9 @@
#define COSINE_MAX_PACKET_LEN 65536 #define COSINE_MAX_PACKET_LEN 65536
static gboolean empty_line(const gchar *line); static gboolean empty_line(const gchar *line);
static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr); static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
static gboolean cosine_check_file_type(wtap *wth, int *err); char *hdr);
static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info);
static gboolean cosine_read(wtap *wth, int *err, gchar **err_info, static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset); gint64 *data_offset);
static gboolean cosine_seek_read(wtap *wth, gint64 seek_off, static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
@ -201,8 +202,10 @@ static gboolean empty_line(const gchar *line)
/* Seeks to the beginning of the next packet, and returns the /* Seeks to the beginning of the next packet, and returns the
byte offset. Copy the header line to hdr. Returns -1 on failure, byte offset. Copy the header line to hdr. Returns -1 on failure,
and sets "*err" to the error and set hdr as NULL. */ and sets "*err" to the error, sets "*err_info" to null or an
static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr) additional error string, and sets hdr to NULL. */
static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
char *hdr)
{ {
gint64 cur_off; gint64 cur_off;
char buf[COSINE_LINE_LENGTH]; char buf[COSINE_LINE_LENGTH];
@ -211,7 +214,7 @@ static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr)
cur_off = file_tell(wth->fh); cur_off = file_tell(wth->fh);
if (cur_off == -1) { if (cur_off == -1) {
/* Error */ /* Error */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
hdr = NULL; hdr = NULL;
return -1; return -1;
} }
@ -227,7 +230,7 @@ static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr)
*err = 0; *err = 0;
} else { } else {
/* We got an error. */ /* We got an error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
} }
break; break;
} }
@ -240,9 +243,10 @@ static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr)
* a CoSine L2 debug output. * a CoSine L2 debug output.
* *
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error; * Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
* if we get an I/O error, "*err" will be set to a non-zero value. * if we get an I/O error, "*err" will be set to a non-zero value and
* "*err_info" will be set to null or an additional error string.
*/ */
static gboolean cosine_check_file_type(wtap *wth, int *err) static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info)
{ {
char buf[COSINE_LINE_LENGTH]; char buf[COSINE_LINE_LENGTH];
gsize reclen; gsize reclen;
@ -268,7 +272,7 @@ static gboolean cosine_check_file_type(wtap *wth, int *err)
if (file_eof(wth->fh)) if (file_eof(wth->fh))
*err = 0; *err = 0;
else else
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; return FALSE;
} }
} }
@ -277,10 +281,10 @@ static gboolean cosine_check_file_type(wtap *wth, int *err)
} }
int cosine_open(wtap *wth, int *err, gchar **err_info _U_) int cosine_open(wtap *wth, int *err, gchar **err_info)
{ {
/* Look for CoSine header */ /* Look for CoSine header */
if (!cosine_check_file_type(wth, err)) { if (!cosine_check_file_type(wth, err, err_info)) {
if (*err == 0) if (*err == 0)
return 0; return 0;
else else
@ -311,7 +315,7 @@ static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
char line[COSINE_LINE_LENGTH]; char line[COSINE_LINE_LENGTH];
/* Find the next packet */ /* Find the next packet */
offset = cosine_seek_next_packet(wth, err, line); offset = cosine_seek_next_packet(wth, err, err_info, line);
if (offset < 0) if (offset < 0)
return FALSE; return FALSE;
@ -348,7 +352,7 @@ cosine_seek_read (wtap *wth, gint64 seek_off,
return FALSE; return FALSE;
if (file_gets(line, COSINE_LINE_LENGTH, wth->random_fh) == NULL) { if (file_gets(line, COSINE_LINE_LENGTH, wth->random_fh) == NULL) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -472,7 +476,7 @@ parse_cosine_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err,
for (i = 0; i < hex_lines; i++) { for (i = 0; i < hex_lines; i++) {
if (file_gets(line, COSINE_LINE_LENGTH, fh) == NULL) { if (file_gets(line, COSINE_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }

View File

@ -61,7 +61,7 @@ typedef struct {
} csids_t; } csids_t;
/* XXX - return -1 on I/O error and actually do something with 'err'. */ /* XXX - return -1 on I/O error and actually do something with 'err'. */
int csids_open(wtap *wth, int *err, gchar **err_info _U_) int csids_open(wtap *wth, int *err, gchar **err_info)
{ {
/* There is no file header. There is only a header for each packet /* There is no file header. There is only a header for each packet
* so we read a packet header and compare the caplen with iplen. They * so we read a packet header and compare the caplen with iplen. They
@ -80,7 +80,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
/* check the file to make sure it is a csids file. */ /* check the file to make sure it is a csids file. */
bytesRead = file_read( &hdr, sizeof( struct csids_header), wth->fh ); bytesRead = file_read( &hdr, sizeof( struct csids_header), wth->fh );
if( bytesRead != sizeof( struct csids_header) ) { if( bytesRead != sizeof( struct csids_header) ) {
*err = file_error( wth->fh ); *err = file_error( wth->fh, err_info );
if( *err != 0 ) { if( *err != 0 ) {
return -1; return -1;
} else { } else {
@ -94,7 +94,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
hdr.caplen = pntohs( &hdr.caplen ); hdr.caplen = pntohs( &hdr.caplen );
bytesRead = file_read( &tmp, 2, wth->fh ); bytesRead = file_read( &tmp, 2, wth->fh );
if( bytesRead != 2 ) { if( bytesRead != 2 ) {
*err = file_error( wth->fh ); *err = file_error( wth->fh, err_info );
if( *err != 0 ) { if( *err != 0 ) {
return -1; return -1;
} else { } else {
@ -103,7 +103,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
} }
bytesRead = file_read( &iplen, 2, wth->fh ); bytesRead = file_read( &iplen, 2, wth->fh );
if( bytesRead != 2 ) { if( bytesRead != 2 ) {
*err = file_error( wth->fh ); *err = file_error( wth->fh, err_info );
if( *err != 0 ) { if( *err != 0 ) {
return -1; return -1;
} else { } else {
@ -151,7 +151,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
} }
/* Find the next packet and parse it; called from wtap_read(). */ /* Find the next packet and parse it; called from wtap_read(). */
static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_, static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset) gint64 *data_offset)
{ {
csids_t *csids = (csids_t *)wth->priv; csids_t *csids = (csids_t *)wth->priv;
@ -163,7 +163,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
bytesRead = file_read( &hdr, sizeof( struct csids_header) , wth->fh ); bytesRead = file_read( &hdr, sizeof( struct csids_header) , wth->fh );
if( bytesRead != sizeof( struct csids_header) ) { if( bytesRead != sizeof( struct csids_header) ) {
*err = file_error( wth->fh ); *err = file_error( wth->fh, err_info );
if (*err == 0 && bytesRead != 0) if (*err == 0 && bytesRead != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -179,7 +179,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
bytesRead = file_read( buf, hdr.caplen, wth->fh ); bytesRead = file_read( buf, hdr.caplen, wth->fh );
if( bytesRead != hdr.caplen ) { if( bytesRead != hdr.caplen ) {
*err = file_error( wth->fh ); *err = file_error( wth->fh, err_info );
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -220,7 +220,7 @@ csids_seek_read (wtap *wth,
bytesRead = file_read( &hdr, sizeof( struct csids_header), wth->random_fh ); bytesRead = file_read( &hdr, sizeof( struct csids_header), wth->random_fh );
if( bytesRead != sizeof( struct csids_header) ) { if( bytesRead != sizeof( struct csids_header) ) {
*err = file_error( wth->random_fh ); *err = file_error( wth->random_fh, err_info );
if( *err == 0 ) { if( *err == 0 ) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -238,7 +238,7 @@ csids_seek_read (wtap *wth,
bytesRead = file_read( pd, hdr.caplen, wth->random_fh ); bytesRead = file_read( pd, hdr.caplen, wth->random_fh );
if( bytesRead != hdr.caplen ) { if( bytesRead != hdr.caplen ) {
*err = file_error( wth->random_fh ); *err = file_error( wth->random_fh, err_info );
if( *err == 0 ) { if( *err == 0 ) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }

View File

@ -89,13 +89,13 @@ static char seekLine[DAINTREE_MAX_LINE_SIZE];
static char readData[READDATA_BUF_SIZE]; static char readData[READDATA_BUF_SIZE];
static char seekData[SEEKDATA_BUF_SIZE]; static char seekData[SEEKDATA_BUF_SIZE];
static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info _U_, static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset); gint64 *data_offset);
static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off, static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header _U_, union wtap_pseudo_header *pseudo_header _U_,
guchar *pd, int len, int *err, guchar *pd, int len, int *err,
gchar **err_info _U_); gchar **err_info);
static guint daintree_sna_hex_char(guchar *str, int *err); static guint daintree_sna_hex_char(guchar *str, int *err);
@ -136,7 +136,7 @@ int daintree_sna_open(wtap *wth, int *err _U_, gchar **err_info _U_)
/* Read the capture file sequentially /* Read the capture file sequentially
* Wireshark scans the file with sequential reads during preview and initial display. */ * Wireshark scans the file with sequential reads during preview and initial display. */
static gboolean static gboolean
daintree_sna_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{ {
guint64 seconds; guint64 seconds;
@ -146,7 +146,7 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset
* if others appear in the file, they are tossed */ * if others appear in the file, they are tossed */
do { do {
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh) == NULL) { if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh) == NULL) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; /* all done */ return FALSE; /* all done */
} }
wth->data_offset += strlen(readLine); wth->data_offset += strlen(readLine);
@ -200,7 +200,7 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset
static gboolean static gboolean
daintree_sna_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header daintree_sna_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
*pseudo_header _U_, guchar *pd, int len, int *err, *pseudo_header _U_, guchar *pd, int len, int *err,
gchar **err_info _U_) gchar **err_info)
{ {
guint pkt_len; guint pkt_len;
@ -211,7 +211,7 @@ daintree_sna_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
* if we find any others, we toss them */ * if we find any others, we toss them */
do { do {
if (file_gets(seekLine, DAINTREE_MAX_LINE_SIZE, wth->random_fh) == NULL) { if (file_gets(seekLine, DAINTREE_MAX_LINE_SIZE, wth->random_fh) == NULL) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
return FALSE; /* all done */ return FALSE; /* all done */
} }
} while (seekLine[0] == COMMENT_LINE); } while (seekLine[0] == COMMENT_LINE);

View File

@ -100,8 +100,10 @@ static guint parse_single_hex_dump_line(char* rec, guint8 *buf,
static guint parse_hex_dump(char* dump, guint8 *buf, char seperator, char end); static guint parse_hex_dump(char* dump, guint8 *buf, char seperator, char end);
/* Seeks to the beginning of the next packet, and returns the /* Seeks to the beginning of the next packet, and returns the
byte offset. Returns -1 on failure, and sets "*err" to the error. */ byte offset. Returns -1 on failure, and sets "*err" to the error
static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err) and "*err_info" to null or an additional error string. */
static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err,
gchar **err_info)
{ {
int byte; int byte;
unsigned int level = 0; unsigned int level = 0;
@ -115,7 +117,7 @@ static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err)
cur_off = file_tell(wth->fh); cur_off = file_tell(wth->fh);
if (cur_off == -1) { if (cur_off == -1) {
/* Error. */ /* Error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return -1; return -1;
} }
return cur_off + 1; return cur_off + 1;
@ -129,7 +131,7 @@ static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err)
*err = 0; *err = 0;
} else { } else {
/* We got an error. */ /* We got an error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
} }
return -1; return -1;
} }
@ -141,9 +143,11 @@ static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err)
* a DBS Ethertrace text trace file. * a DBS Ethertrace text trace file.
* *
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error; * Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
* if we get an I/O error, "*err" will be set to a non-zero value. * if we get an I/O error, "*err" will be set to a non-zero value and
* "*err_info" will be set to null or an error string.
*/ */
static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err) static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
gchar **err_info)
{ {
char buf[DBS_ETHERWATCH_LINE_LENGTH]; char buf[DBS_ETHERWATCH_LINE_LENGTH];
int line, byte; int line, byte;
@ -178,7 +182,7 @@ static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err)
if (file_eof(wth->fh)) if (file_eof(wth->fh))
*err = 0; *err = 0;
else else
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; return FALSE;
} }
} }
@ -187,10 +191,10 @@ static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err)
} }
int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info _U_) int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
{ {
/* Look for DBS ETHERWATCH header */ /* Look for DBS ETHERWATCH header */
if (!dbs_etherwatch_check_file_type(wth, err)) { if (!dbs_etherwatch_check_file_type(wth, err, err_info)) {
if (*err == 0) if (*err == 0)
return 0; return 0;
else else
@ -217,7 +221,7 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
int pkt_len; int pkt_len;
/* Find the next packet */ /* Find the next packet */
offset = dbs_etherwatch_seek_next_packet(wth, err); offset = dbs_etherwatch_seek_next_packet(wth, err, err_info);
if (offset < 1) if (offset < 1)
return FALSE; return FALSE;
@ -335,7 +339,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err,
* extract the useful information * extract the useful information
*/ */
if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) { if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -378,7 +382,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err,
/* Read the next line of the record header */ /* Read the next line of the record header */
if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) { if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -489,7 +493,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err,
count = 0; count = 0;
while (count < pkt_len) { while (count < pkt_len) {
if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) { if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }

View File

@ -162,9 +162,10 @@ xml_get_int(int *val, const unsigned char *str, const unsigned char *pattern)
* a DCT3 trace file. * a DCT3 trace file.
* *
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error; * Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
* if we get an I/O error, "*err" will be set to a non-zero value. * if we get an I/O error, "*err" will be set to a non-zero value
* and "*err_info" will be set to null or an additional error string.
*/ */
static gboolean dct3trace_check_file_type(wtap *wth, int *err) static gboolean dct3trace_check_file_type(wtap *wth, int *err, gchar **err_info)
{ {
char line1[64], line2[64]; char line1[64], line2[64];
@ -184,17 +185,17 @@ static gboolean dct3trace_check_file_type(wtap *wth, int *err)
if (file_eof(wth->fh)) if (file_eof(wth->fh))
*err = 0; *err = 0;
else else
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
} }
return FALSE; return FALSE;
} }
int dct3trace_open(wtap *wth, int *err, gchar **err_info _U_) int dct3trace_open(wtap *wth, int *err, gchar **err_info)
{ {
/* Look for Gammu DCT3 trace header */ /* Look for Gammu DCT3 trace header */
if (!dct3trace_check_file_type(wth, err)) if (!dct3trace_check_file_type(wth, err, err_info))
{ {
if (*err == 0) if (*err == 0)
return 0; return 0;
@ -328,7 +329,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, union wtap_pseudo_header *pseudo
} }
} }
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
{ {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;

View File

@ -71,7 +71,7 @@ static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, union wtap_pseudo_header *pseudo_header, guchar *pd,
int length, int *err, gchar **err_info); int length, int *err, gchar **err_info);
extern int erf_open(wtap *wth, int *err, gchar **err_info _U_) extern int erf_open(wtap *wth, int *err, gchar **err_info)
{ {
int i, n, records_for_erf_check = RECORDS_FOR_ERF_CHECK; int i, n, records_for_erf_check = RECORDS_FOR_ERF_CHECK;
int valid_prev = 0; int valid_prev = 0;
@ -108,7 +108,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
if (r == 0 ) break; if (r == 0 ) break;
if (r != sizeof(header)) { if (r != sizeof(header)) {
if ((*err = file_error(wth->fh)) != 0) { if ((*err = file_error(wth->fh, err_info)) != 0) {
return -1; return -1;
} else { } else {
/* ERF header too short accept the file, /* ERF header too short accept the file,
@ -178,7 +178,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
type = header.type; type = header.type;
while (type & 0x80){ while (type & 0x80){
if (file_read(&erf_ext_header, sizeof(erf_ext_header),wth->fh) != sizeof(erf_ext_header)) { if (file_read(&erf_ext_header, sizeof(erf_ext_header),wth->fh) != sizeof(erf_ext_header)) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return -1; return -1;
} }
packet_size -= (guint32)sizeof(erf_ext_header); packet_size -= (guint32)sizeof(erf_ext_header);
@ -197,7 +197,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
case ERF_TYPE_COLOR_MC_HDLC_POS: case ERF_TYPE_COLOR_MC_HDLC_POS:
case ERF_TYPE_AAL2: /* not an MC type but has a similar 'AAL2 ext' header */ case ERF_TYPE_AAL2: /* not an MC type but has a similar 'AAL2 ext' header */
if (file_read(&mc_hdr,sizeof(mc_hdr),wth->fh) != sizeof(mc_hdr)) { if (file_read(&mc_hdr,sizeof(mc_hdr),wth->fh) != sizeof(mc_hdr)) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return -1; return -1;
} }
packet_size -= (guint32)sizeof(mc_hdr); packet_size -= (guint32)sizeof(mc_hdr);
@ -206,7 +206,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
case ERF_TYPE_COLOR_ETH: case ERF_TYPE_COLOR_ETH:
case ERF_TYPE_DSM_COLOR_ETH: case ERF_TYPE_DSM_COLOR_ETH:
if (file_read(&eth_hdr,sizeof(eth_hdr),wth->fh) != sizeof(eth_hdr)) { if (file_read(&eth_hdr,sizeof(eth_hdr),wth->fh) != sizeof(eth_hdr)) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return -1; return -1;
} }
packet_size -= (guint32)sizeof(eth_hdr); packet_size -= (guint32)sizeof(eth_hdr);
@ -282,7 +282,7 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer), wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
(gint32)(packet_size), wth->fh, err ); (gint32)(packet_size), wth->fh, err, err_info);
wth->data_offset += packet_size; wth->data_offset += packet_size;
} while ( erf_header.type == ERF_TYPE_PAD ); } while ( erf_header.type == ERF_TYPE_PAD );
@ -306,7 +306,8 @@ static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
return FALSE; return FALSE;
} while ( erf_header.type == ERF_TYPE_PAD ); } while ( erf_header.type == ERF_TYPE_PAD );
wtap_file_read_expected_bytes(pd, (int)packet_size, wth->random_fh, err); wtap_file_read_expected_bytes(pd, (int)packet_size, wth->random_fh, err,
err_info);
return TRUE; return TRUE;
} }
@ -328,7 +329,8 @@ static int erf_read_header(FILE_T fh,
guint32 skiplen=0; guint32 skiplen=0;
int i = 0 , max = sizeof(pseudo_header->erf.ehdr_list)/sizeof(struct erf_ehdr); int i = 0 , max = sizeof(pseudo_header->erf.ehdr_list)/sizeof(struct erf_ehdr);
wtap_file_read_expected_bytes(erf_header, sizeof(*erf_header), fh, err); wtap_file_read_expected_bytes(erf_header, sizeof(*erf_header), fh, err,
err_info);
if (bytes_read != NULL) { if (bytes_read != NULL) {
*bytes_read = sizeof(*erf_header); *bytes_read = sizeof(*erf_header);
} }
@ -371,7 +373,8 @@ static int erf_read_header(FILE_T fh,
/* Copy the ERF extension header into the pseudo header */ /* Copy the ERF extension header into the pseudo header */
type = erf_header->type; type = erf_header->type;
while (type & 0x80){ while (type & 0x80){
wtap_file_read_expected_bytes(&erf_exhdr, sizeof(erf_exhdr), fh, err); wtap_file_read_expected_bytes(&erf_exhdr, sizeof(erf_exhdr), fh, err,
err_info);
if (bytes_read != NULL) if (bytes_read != NULL)
*bytes_read += (guint32)sizeof(erf_exhdr); *bytes_read += (guint32)sizeof(erf_exhdr);
*packet_size -= (guint32)sizeof(erf_exhdr); *packet_size -= (guint32)sizeof(erf_exhdr);
@ -408,7 +411,8 @@ static int erf_read_header(FILE_T fh,
case ERF_TYPE_ETH: case ERF_TYPE_ETH:
case ERF_TYPE_COLOR_ETH: case ERF_TYPE_COLOR_ETH:
case ERF_TYPE_DSM_COLOR_ETH: case ERF_TYPE_DSM_COLOR_ETH:
wtap_file_read_expected_bytes(&eth_hdr, sizeof(eth_hdr), fh, err); wtap_file_read_expected_bytes(&eth_hdr, sizeof(eth_hdr), fh, err,
err_info);
if (bytes_read != NULL) if (bytes_read != NULL)
*bytes_read += (guint32)sizeof(eth_hdr); *bytes_read += (guint32)sizeof(eth_hdr);
*packet_size -= (guint32)sizeof(eth_hdr); *packet_size -= (guint32)sizeof(eth_hdr);
@ -424,7 +428,8 @@ static int erf_read_header(FILE_T fh,
case ERF_TYPE_MC_AAL2: case ERF_TYPE_MC_AAL2:
case ERF_TYPE_COLOR_MC_HDLC_POS: case ERF_TYPE_COLOR_MC_HDLC_POS:
case ERF_TYPE_AAL2: /* not an MC type but has a similar 'AAL2 ext' header */ case ERF_TYPE_AAL2: /* not an MC type but has a similar 'AAL2 ext' header */
wtap_file_read_expected_bytes(&mc_hdr, sizeof(mc_hdr), fh, err); wtap_file_read_expected_bytes(&mc_hdr, sizeof(mc_hdr), fh, err,
err_info);
if (bytes_read != NULL) if (bytes_read != NULL)
*bytes_read += (guint32)sizeof(mc_hdr); *bytes_read += (guint32)sizeof(mc_hdr);
*packet_size -= (guint32)sizeof(mc_hdr); *packet_size -= (guint32)sizeof(mc_hdr);

View File

@ -159,7 +159,7 @@ static gboolean etherpeek_seek_read_v56(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info); int *err, gchar **err_info);
int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_) int etherpeek_open(wtap *wth, int *err, gchar **err_info)
{ {
etherpeek_header_t ep_hdr; etherpeek_header_t ep_hdr;
struct timeval reference_time; struct timeval reference_time;
@ -176,7 +176,7 @@ int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_)
*/ */
g_assert(sizeof(ep_hdr.master) == ETHERPEEK_MASTER_HDR_SIZE); g_assert(sizeof(ep_hdr.master) == ETHERPEEK_MASTER_HDR_SIZE);
wtap_file_read_unknown_bytes( wtap_file_read_unknown_bytes(
&ep_hdr.master, sizeof(ep_hdr.master), wth->fh, err); &ep_hdr.master, sizeof(ep_hdr.master), wth->fh, err, err_info);
wth->data_offset += sizeof(ep_hdr.master); wth->data_offset += sizeof(ep_hdr.master);
/* /*
@ -204,7 +204,7 @@ int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_)
ETHERPEEK_V567_HDR_SIZE); ETHERPEEK_V567_HDR_SIZE);
wtap_file_read_unknown_bytes( wtap_file_read_unknown_bytes(
&ep_hdr.secondary.v567, &ep_hdr.secondary.v567,
sizeof(ep_hdr.secondary.v567), wth->fh, err); sizeof(ep_hdr.secondary.v567), wth->fh, err, err_info);
wth->data_offset += sizeof(ep_hdr.secondary.v567); wth->data_offset += sizeof(ep_hdr.secondary.v567);
if ((0 != ep_hdr.secondary.v567.reserved[0]) || if ((0 != ep_hdr.secondary.v567.reserved[0]) ||
@ -381,7 +381,8 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
*data_offset = wth->data_offset; *data_offset = wth->data_offset;
wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err); wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err,
err_info);
wth->data_offset += sizeof(ep_pkt); wth->data_offset += sizeof(ep_pkt);
/* Extract the fields from the packet */ /* Extract the fields from the packet */
@ -424,7 +425,8 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
*err_info = g_strdup("etherpeek: packet not long enough for 802.11 radio header"); *err_info = g_strdup("etherpeek: packet not long enough for 802.11 radio header");
return FALSE; return FALSE;
} }
wtap_file_read_expected_bytes(&radio_hdr, 4, wth->fh, err); wtap_file_read_expected_bytes(&radio_hdr, 4, wth->fh, err,
err_info);
/* /*
* We don't treat the radio information as packet data. * We don't treat the radio information as packet data.
@ -449,7 +451,7 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
/* read the frame data */ /* read the frame data */
buffer_assure_space(wth->frame_buffer, sliceLength); buffer_assure_space(wth->frame_buffer, sliceLength);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer), wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
sliceLength, wth->fh, err); sliceLength, wth->fh, err, err_info);
wth->data_offset += sliceLength; wth->data_offset += sliceLength;
/* fill in packet header values */ /* fill in packet header values */
@ -488,7 +490,7 @@ etherpeek_seek_read_v7(wtap *wth, gint64 seek_off,
/* Read the packet header. */ /* Read the packet header. */
wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->random_fh, wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->random_fh,
err); err, err_info);
status = ep_pkt[ETHERPEEK_V7_STATUS_OFFSET]; status = ep_pkt[ETHERPEEK_V7_STATUS_OFFSET];
switch (wth->file_encap) { switch (wth->file_encap) {
@ -507,7 +509,7 @@ etherpeek_seek_read_v7(wtap *wth, gint64 seek_off,
return FALSE; return FALSE;
} }
wtap_file_read_expected_bytes(&radio_hdr, 4, wth->random_fh, wtap_file_read_expected_bytes(&radio_hdr, 4, wth->random_fh,
err); err, err_info);
etherpeek_fill_pseudo_header_v7(pseudo_header, etherpeek_fill_pseudo_header_v7(pseudo_header,
&radio_hdr); &radio_hdr);
@ -525,7 +527,8 @@ etherpeek_seek_read_v7(wtap *wth, gint64 seek_off,
* XXX - should "errno" be set in "wtap_file_read_expected_bytes()"? * XXX - should "errno" be set in "wtap_file_read_expected_bytes()"?
*/ */
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
wtap_file_read_expected_bytes(pd, length, wth->random_fh, err); wtap_file_read_expected_bytes(pd, length, wth->random_fh, err,
err_info);
return TRUE; return TRUE;
} }
@ -539,7 +542,7 @@ etherpeek_fill_pseudo_header_v7(union wtap_pseudo_header *pseudo_header,
pseudo_header->ieee_802_11.signal_level = radio_hdr->signal_level; pseudo_header->ieee_802_11.signal_level = radio_hdr->signal_level;
} }
static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_, static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset) gint64 *data_offset)
{ {
etherpeek_t *etherpeek = (etherpeek_t *)wth->priv; etherpeek_t *etherpeek = (etherpeek_t *)wth->priv;
@ -571,7 +574,8 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
*/ */
*data_offset = wth->data_offset; *data_offset = wth->data_offset;
wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err); wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err,
err_info);
wth->data_offset += sizeof(ep_pkt); wth->data_offset += sizeof(ep_pkt);
/* Extract the fields from the packet */ /* Extract the fields from the packet */
@ -603,7 +607,7 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
/* read the frame data */ /* read the frame data */
buffer_assure_space(wth->frame_buffer, sliceLength); buffer_assure_space(wth->frame_buffer, sliceLength);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer), wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
sliceLength, wth->fh, err); sliceLength, wth->fh, err, err_info);
wth->data_offset += sliceLength; wth->data_offset += sliceLength;
/* fill in packet header values */ /* fill in packet header values */
@ -634,7 +638,7 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
static gboolean static gboolean
etherpeek_seek_read_v56(wtap *wth, gint64 seek_off, etherpeek_seek_read_v56(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE]; guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE];
int pkt_encap; int pkt_encap;
@ -645,7 +649,7 @@ etherpeek_seek_read_v56(wtap *wth, gint64 seek_off,
return FALSE; return FALSE;
wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->random_fh, wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->random_fh,
err); err, err_info);
protoNum = pntohs(&ep_pkt[ETHERPEEK_V56_PROTONUM_OFFSET]); protoNum = pntohs(&ep_pkt[ETHERPEEK_V56_PROTONUM_OFFSET]);
pkt_encap = WTAP_ENCAP_UNKNOWN; pkt_encap = WTAP_ENCAP_UNKNOWN;
@ -667,6 +671,7 @@ etherpeek_seek_read_v56(wtap *wth, gint64 seek_off,
* XXX - should "errno" be set in "wtap_file_read_expected_bytes()"? * XXX - should "errno" be set in "wtap_file_read_expected_bytes()"?
*/ */
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
wtap_file_read_expected_bytes(pd, length, wth->random_fh, err); wtap_file_read_expected_bytes(pd, length, wth->random_fh, err,
err_info);
return TRUE; return TRUE;
} }

View File

@ -105,8 +105,9 @@ static int parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
/* Seeks to the beginning of the next packet, and returns the /* Seeks to the beginning of the next packet, and returns the
byte offset. Returns -1 on failure, and sets "*err" to the error. */ byte offset. Returns -1 on failure, and sets "*err" to the error
static gint64 eyesdn_seek_next_packet(wtap *wth, int *err) and "*err_info" to null or an additional error string. */
static gint64 eyesdn_seek_next_packet(wtap *wth, int *err, gchar **err_info)
{ {
int byte; int byte;
gint64 cur_off; gint64 cur_off;
@ -116,7 +117,7 @@ static gint64 eyesdn_seek_next_packet(wtap *wth, int *err)
cur_off = file_tell(wth->fh); cur_off = file_tell(wth->fh);
if (cur_off == -1) { if (cur_off == -1) {
/* Error. */ /* Error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return -1; return -1;
} }
return cur_off; return cur_off;
@ -127,12 +128,12 @@ static gint64 eyesdn_seek_next_packet(wtap *wth, int *err)
*err = 0; *err = 0;
} else { } else {
/* We got an error. */ /* We got an error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
} }
return -1; return -1;
} }
int eyesdn_open(wtap *wth, int *err, gchar **err_info _U_) int eyesdn_open(wtap *wth, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
char magic[EYESDN_HDR_MAGIC_SIZE]; char magic[EYESDN_HDR_MAGIC_SIZE];
@ -141,7 +142,7 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info _U_)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&magic, sizeof magic, wth->fh); bytes_read = file_read(&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) { if (bytes_read != sizeof magic) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -169,7 +170,7 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
int pkt_len; int pkt_len;
/* Find the next packet */ /* Find the next packet */
offset = eyesdn_seek_next_packet(wth, err); offset = eyesdn_seek_next_packet(wth, err, err_info);
if (offset < 1) if (offset < 1)
return FALSE; return FALSE;
@ -235,7 +236,7 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
* information. * information.
*/ */
if (esc_read(hdr, EYESDN_HDR_LENGTH, fh) != EYESDN_HDR_LENGTH) { if (esc_read(hdr, EYESDN_HDR_LENGTH, fh) != EYESDN_HDR_LENGTH) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -304,7 +305,7 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
cur_off = file_tell(fh); cur_off = file_tell(fh);
if (esc_read(cell, CELL_LEN, fh) != CELL_LEN) { if (esc_read(cell, CELL_LEN, fh) != CELL_LEN) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -386,7 +387,7 @@ parse_eyesdn_packet_data(FILE_T fh, int pkt_len, guint8* buf, int *err,
bytes_read = esc_read(buf, pkt_len, fh); bytes_read = esc_read(buf, pkt_len, fh);
if (bytes_read != pkt_len) { if (bytes_read != pkt_len) {
if (bytes_read == -2) { if (bytes_read == -2) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} else if (bytes_read == -1) { } else if (bytes_read == -1) {

View File

@ -91,6 +91,7 @@ struct wtap_reader {
int seek; /* true if seek request pending */ int seek; /* true if seek request pending */
/* error information */ /* error information */
int err; /* error code */ int err; /* error code */
char *err_info; /* additional error information string for some errors */
unsigned int avail_in; /* number of bytes available at next_in */ unsigned int avail_in; /* number of bytes available at next_in */
unsigned char *next_in; /* next input byte */ unsigned char *next_in; /* next input byte */
@ -402,7 +403,8 @@ zlib_read(FILE_T state, unsigned char *buf, unsigned int count)
if (state->avail_in == 0 && fill_in_buffer(state) == -1) if (state->avail_in == 0 && fill_in_buffer(state) == -1)
break; break;
if (state->avail_in == 0) { if (state->avail_in == 0) {
state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR; /* EOF */
state->err = WTAP_ERR_SHORT_READ;
break; break;
} }
@ -413,8 +415,14 @@ zlib_read(FILE_T state, unsigned char *buf, unsigned int count)
ret = inflate(strm, Z_BLOCK); ret = inflate(strm, Z_BLOCK);
state->avail_in = strm->avail_in; state->avail_in = strm->avail_in;
state->next_in = strm->next_in; state->next_in = strm->next_in;
if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { if (ret == Z_STREAM_ERROR) {
state->err = WTAP_ERR_ZLIB + Z_STREAM_ERROR; state->err = WTAP_ERR_DECOMPRESS;
state->err_info = strm->msg;
break;
}
if (ret == Z_NEED_DICT) {
state->err = WTAP_ERR_DECOMPRESS;
state->err_info = "preset dictionary needed";
break; break;
} }
if (ret == Z_MEM_ERROR) { if (ret == Z_MEM_ERROR) {
@ -423,7 +431,8 @@ zlib_read(FILE_T state, unsigned char *buf, unsigned int count)
break; break;
} }
if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ if (ret == Z_DATA_ERROR) { /* deflate stream invalid */
state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR; state->err = WTAP_ERR_DECOMPRESS;
state->err_info = strm->msg;
break; break;
} }
/* /*
@ -480,10 +489,13 @@ zlib_read(FILE_T state, unsigned char *buf, unsigned int count)
if (ret == Z_STREAM_END) { if (ret == Z_STREAM_END) {
if (gz_next4(state, &crc) != -1 && if (gz_next4(state, &crc) != -1 &&
gz_next4(state, &len) != -1) { gz_next4(state, &len) != -1) {
if (crc != strm->adler) if (crc != strm->adler) {
state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR; state->err = WTAP_ERR_DECOMPRESS;
if (len != (strm->total_out & 0xffffffffL)) state->err_info = "bad CRC";
state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR; } else if (len != (strm->total_out & 0xffffffffL)) {
state->err = WTAP_ERR_DECOMPRESS;
state->err_info = "length field wrong";
}
} }
state->compression = UNKNOWN; /* ready for next stream, once have is 0 */ state->compression = UNKNOWN; /* ready for next stream, once have is 0 */
g_free(state->fast_seek_cur); g_free(state->fast_seek_cur);
@ -526,7 +538,8 @@ gz_head(FILE_T state)
if (gz_next1(state, &cm) == -1) if (gz_next1(state, &cm) == -1)
return -1; return -1;
if (cm != 8) { if (cm != 8) {
state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR; state->err = WTAP_ERR_DECOMPRESS;
state->err_info = "unknown compression method";
return -1; return -1;
} }
@ -534,7 +547,8 @@ gz_head(FILE_T state)
if (gz_next1(state, &flags) == -1) if (gz_next1(state, &flags) == -1)
return -1; return -1;
if (flags & 0xe0) { /* reserved flag bits */ if (flags & 0xe0) { /* reserved flag bits */
state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR; state->err = WTAP_ERR_DECOMPRESS;
state->err_info = "reserved flag bits set";
return -1; return -1;
} }
@ -686,6 +700,7 @@ gz_reset(FILE_T state)
state->seek = 0; /* no seek request pending */ state->seek = 0; /* no seek request pending */
state->err = 0; /* clear error */ state->err = 0; /* clear error */
state->err_info = NULL;
state->pos = 0; /* no uncompressed data yet */ state->pos = 0; /* no uncompressed data yet */
state->avail_in = 0; /* no input data yet */ state->avail_in = 0; /* no input data yet */
} }
@ -844,6 +859,7 @@ file_seek(FILE_T file, gint64 offset, int whence, int *err)
file->eof = 0; file->eof = 0;
file->seek = 0; file->seek = 0;
file->err = 0; file->err = 0;
file->err_info = NULL;
file->avail_in = 0; file->avail_in = 0;
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
@ -902,6 +918,7 @@ file_seek(FILE_T file, gint64 offset, int whence, int *err)
file->eof = 0; file->eof = 0;
file->seek = 0; file->seek = 0;
file->err = 0; file->err = 0;
file->err_info = NULL;
file->avail_in = 0; file->avail_in = 0;
file->pos += offset; file->pos += offset;
return file->pos; return file->pos;
@ -1105,12 +1122,16 @@ file_eof(FILE_T file)
/* /*
* Routine to return a Wiretap error code (0 for no error, an errno * Routine to return a Wiretap error code (0 for no error, an errno
* for a file error, or a WTAP_ERR_ code for other errors) for an * for a file error, or a WTAP_ERR_ code for other errors) for an
* I/O stream. * I/O stream. Also returns an error string for some errors.
*/ */
int int
file_error(FILE_T fh) file_error(FILE_T fh, gchar **err_info)
{ {
return fh->err; if (fh->err != 0) {
*err_info = (fh->err_info == NULL) ? NULL : g_strdup(fh->err_info);
return fh->err;
}
return 0;
} }
void void
@ -1118,6 +1139,7 @@ file_clearerr(FILE_T stream)
{ {
/* clear error and end-of-file */ /* clear error and end-of-file */
stream->err = 0; stream->err = 0;
stream->err_info = NULL;
stream->eof = 0; stream->eof = 0;
} }
@ -1136,6 +1158,7 @@ file_close(FILE_T file)
} }
g_free(file->fast_seek_cur); g_free(file->fast_seek_cur);
file->err = 0; file->err = 0;
file->err_info = NULL;
g_free(file); g_free(file);
return close(fd); return close(fd);
} }

View File

@ -26,7 +26,7 @@
extern gint64 file_seek(FILE_T stream, gint64 offset, int whence, int *err); extern gint64 file_seek(FILE_T stream, gint64 offset, int whence, int *err);
extern gint64 file_tell(FILE_T stream); extern gint64 file_tell(FILE_T stream);
extern int file_error(FILE_T fh); extern int file_error(FILE_T fh, gchar **err_info);
extern FILE_T file_open(const char *path); extern FILE_T file_open(const char *path);
extern FILE_T filed_open(int fildes); extern FILE_T filed_open(int fildes);

View File

@ -49,7 +49,7 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->fh); bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->fh);
if (bytes_read != DUMP_HDR_SIZE) { if (bytes_read != DUMP_HDR_SIZE) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -73,7 +73,7 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
bytes_read = file_read(buf, packet_size, wth->fh); bytes_read = file_read(buf, packet_size, wth->fh);
if (bytes_read != packet_size) { if (bytes_read != packet_size) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -92,7 +92,7 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off, static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd, int length, union wtap_pseudo_header *pseudo_header, guint8 *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
struct dump_hdr dh; struct dump_hdr dh;
int bytes_read; int bytes_read;
@ -102,7 +102,7 @@ static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->random_fh); bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->random_fh);
if (bytes_read != DUMP_HDR_SIZE) { if (bytes_read != DUMP_HDR_SIZE) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -110,7 +110,7 @@ static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
bytes_read = file_read(pd, length, wth->random_fh); bytes_read = file_read(pd, length, wth->random_fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -121,7 +121,7 @@ static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
return TRUE; return TRUE;
} }
int hcidump_open(wtap *wth, int *err, gchar **err_info _U_) int hcidump_open(wtap *wth, int *err, gchar **err_info)
{ {
struct dump_hdr dh; struct dump_hdr dh;
guint8 type; guint8 type;
@ -129,7 +129,7 @@ int hcidump_open(wtap *wth, int *err, gchar **err_info _U_)
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->fh); bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->fh);
if (bytes_read != DUMP_HDR_SIZE) { if (bytes_read != DUMP_HDR_SIZE) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return (*err != 0) ? -1 : 0; return (*err != 0) ? -1 : 0;
} }
@ -139,7 +139,7 @@ int hcidump_open(wtap *wth, int *err, gchar **err_info _U_)
bytes_read = file_read(&type, 1, wth->fh); bytes_read = file_read(&type, 1, wth->fh);
if (bytes_read != 1) { if (bytes_read != 1) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return (*err != 0) ? -1 : 0; return (*err != 0) ? -1 : 0;
} }

View File

@ -42,9 +42,11 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off, static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info); int *err, gchar **err_info);
static int i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err); static int i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err,
gchar **err_info);
static void i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr); static void i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr);
static gboolean i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err); static gboolean i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info);
static void i4b_set_pseudo_header(i4b_trace_hdr_t *hdr, static void i4b_set_pseudo_header(i4b_trace_hdr_t *hdr,
union wtap_pseudo_header *pseudo_header); union wtap_pseudo_header *pseudo_header);
@ -56,7 +58,7 @@ static void i4b_set_pseudo_header(i4b_trace_hdr_t *hdr,
(unsigned)hdr.unit > 4 || (unsigned)hdr.type > 4 || \ (unsigned)hdr.unit > 4 || (unsigned)hdr.type > 4 || \
(unsigned)hdr.dir > 2 || (unsigned)hdr.trunc > 2048)) (unsigned)hdr.dir > 2 || (unsigned)hdr.trunc > 2048))
int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_) int i4btrace_open(wtap *wth, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
i4b_trace_hdr_t hdr; i4b_trace_hdr_t hdr;
@ -67,7 +69,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof(hdr), wth->fh); bytes_read = file_read(&hdr, sizeof(hdr), wth->fh);
if (bytes_read != sizeof(hdr)) { if (bytes_read != sizeof(hdr)) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -129,7 +131,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
/* Read record header. */ /* Read record header. */
*data_offset = wth->data_offset; *data_offset = wth->data_offset;
ret = i4b_read_rec_header(wth->fh, &hdr, err); ret = i4b_read_rec_header(wth->fh, &hdr, err, err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
return FALSE; return FALSE;
@ -155,7 +157,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
*/ */
buffer_assure_space(wth->frame_buffer, length); buffer_assure_space(wth->frame_buffer, length);
bufp = buffer_start_ptr(wth->frame_buffer); bufp = buffer_start_ptr(wth->frame_buffer);
if (!i4b_read_rec_data(wth->fh, bufp, length, err)) if (!i4b_read_rec_data(wth->fh, bufp, length, err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += length; wth->data_offset += length;
@ -188,7 +190,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
static gboolean static gboolean
i4btrace_seek_read(wtap *wth, gint64 seek_off, i4btrace_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
int ret; int ret;
i4b_trace_hdr_t hdr; i4b_trace_hdr_t hdr;
@ -197,7 +199,7 @@ i4btrace_seek_read(wtap *wth, gint64 seek_off,
return FALSE; return FALSE;
/* Read record header. */ /* Read record header. */
ret = i4b_read_rec_header(wth->random_fh, &hdr, err); ret = i4b_read_rec_header(wth->random_fh, &hdr, err, err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
if (ret == 0) { if (ret == 0) {
@ -213,18 +215,18 @@ i4btrace_seek_read(wtap *wth, gint64 seek_off,
/* /*
* Read the packet data. * Read the packet data.
*/ */
return i4b_read_rec_data(wth->random_fh, pd, length, err); return i4b_read_rec_data(wth->random_fh, pd, length, err, err_info);
} }
static int static int
i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err) i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(hdr, sizeof *hdr, fh); bytes_read = file_read(hdr, sizeof *hdr, fh);
if (bytes_read != sizeof *hdr) { if (bytes_read != sizeof *hdr) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
if (bytes_read != 0) { if (bytes_read != 0) {
@ -257,7 +259,7 @@ i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr)
} }
static gboolean static gboolean
i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -265,7 +267,7 @@ i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
bytes_read = file_read(pd, length, fh); bytes_read = file_read(pd, length, fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -128,7 +128,7 @@ typedef struct ipfix_set_header_s {
static gboolean static gboolean
ipfix_read_message_header(ipfix_message_header_t *pfx_hdr, FILE_T fh, int *err, gchar **err_info) ipfix_read_message_header(ipfix_message_header_t *pfx_hdr, FILE_T fh, int *err, gchar **err_info)
{ {
wtap_file_read_expected_bytes(pfx_hdr, IPFIX_MSG_HDR_SIZE, fh, err); /* macro which does a return if read fails */ wtap_file_read_expected_bytes(pfx_hdr, IPFIX_MSG_HDR_SIZE, fh, err, err_info); /* macro which does a return if read fails */
/* fix endianess, because IPFIX files are always big-endian */ /* fix endianess, because IPFIX files are always big-endian */
pfx_hdr->version = g_ntohs(pfx_hdr->version); pfx_hdr->version = g_ntohs(pfx_hdr->version);
@ -218,7 +218,7 @@ ipfix_open(wtap *wth, int *err, gchar **err_info)
/* check each Set in IPFIX Message for sanity */ /* check each Set in IPFIX Message for sanity */
while (checked_len < msg_hdr.message_length) { while (checked_len < msg_hdr.message_length) {
wtap_file_read_expected_bytes(&set_hdr, IPFIX_SET_HDR_SIZE, wth->fh, err); wtap_file_read_expected_bytes(&set_hdr, IPFIX_SET_HDR_SIZE, wth->fh, err, err_info);
set_hdr.set_length = g_ntohs(set_hdr.set_length); set_hdr.set_length = g_ntohs(set_hdr.set_length);
if ((set_hdr.set_length < IPFIX_SET_HDR_SIZE) || if ((set_hdr.set_length < IPFIX_SET_HDR_SIZE) ||
((set_hdr.set_length + checked_len) > msg_hdr.message_length)) { ((set_hdr.set_length + checked_len) > msg_hdr.message_length)) {
@ -273,7 +273,7 @@ ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
buffer_assure_space(wth->frame_buffer, msg_hdr.message_length); buffer_assure_space(wth->frame_buffer, msg_hdr.message_length);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer), wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
msg_hdr.message_length, wth->fh, err); msg_hdr.message_length, wth->fh, err, err_info);
wth->phdr.len = msg_hdr.message_length; wth->phdr.len = msg_hdr.message_length;
wth->phdr.caplen = msg_hdr.message_length; wth->phdr.caplen = msg_hdr.message_length;
@ -320,7 +320,7 @@ ipfix_seek_read(wtap *wth, gint64 seek_off,
return FALSE; return FALSE;
} }
wtap_file_read_expected_bytes(pd, length, wth->random_fh, err); wtap_file_read_expected_bytes(pd, length, wth->random_fh, err, err_info);
return TRUE; return TRUE;
} }

View File

@ -45,14 +45,14 @@ static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
int *err, gchar **err_info); int *err, gchar **err_info);
static int iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len, static int iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len,
int *err); int *err, gchar **err_info);
static gboolean iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, static gboolean iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr,
int packet_size, int *err); int packet_size, int *err, gchar **err_info);
static void fill_in_pseudo_header(int encap, const guint8 *pd, guint32 len, static void fill_in_pseudo_header(int encap, const guint8 *pd, guint32 len,
union wtap_pseudo_header *pseudo_header, guint8 *header); union wtap_pseudo_header *pseudo_header, guint8 *header);
static int wtap_encap_ift(unsigned int ift); static int wtap_encap_ift(unsigned int ift);
int iptrace_open(wtap *wth, int *err, gchar **err_info _U_) int iptrace_open(wtap *wth, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
char name[12]; char name[12];
@ -60,7 +60,7 @@ int iptrace_open(wtap *wth, int *err, gchar **err_info _U_)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(name, 11, wth->fh); bytes_read = file_read(name, 11, wth->fh);
if (bytes_read != 11) { if (bytes_read != 11) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -123,7 +123,7 @@ typedef struct {
#define IPTRACE_1_0_PDATA_SIZE 22 /* packet data */ #define IPTRACE_1_0_PDATA_SIZE 22 /* packet data */
/* Read the next packet */ /* Read the next packet */
static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_, static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset) gint64 *data_offset)
{ {
int ret; int ret;
@ -136,7 +136,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_,
/* Read the descriptor data */ /* Read the descriptor data */
*data_offset = wth->data_offset; *data_offset = wth->data_offset;
ret = iptrace_read_rec_header(wth->fh, header, IPTRACE_1_0_PHDR_SIZE, ret = iptrace_read_rec_header(wth->fh, header, IPTRACE_1_0_PHDR_SIZE,
err); err, err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
return FALSE; return FALSE;
@ -169,13 +169,15 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_,
/* /*
* Read the padding. * Read the padding.
*/ */
if (!iptrace_read_rec_data(wth->fh, fddi_padding, 3, err)) if (!iptrace_read_rec_data(wth->fh, fddi_padding, 3, err,
err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
} }
buffer_assure_space( wth->frame_buffer, packet_size ); buffer_assure_space( wth->frame_buffer, packet_size );
data_ptr = buffer_start_ptr( wth->frame_buffer ); data_ptr = buffer_start_ptr( wth->frame_buffer );
if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err)) if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err,
err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -213,7 +215,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_,
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off, static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
int ret; int ret;
guint8 header[IPTRACE_1_0_PHDR_SIZE]; guint8 header[IPTRACE_1_0_PHDR_SIZE];
@ -225,7 +227,7 @@ static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
/* Read the descriptor data */ /* Read the descriptor data */
ret = iptrace_read_rec_header(wth->random_fh, header, ret = iptrace_read_rec_header(wth->random_fh, header,
IPTRACE_1_0_PHDR_SIZE, err); IPTRACE_1_0_PHDR_SIZE, err, err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
if (ret == 0) { if (ret == 0) {
@ -248,12 +250,14 @@ static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
/* /*
* Read the padding. * Read the padding.
*/ */
if (!iptrace_read_rec_data(wth->random_fh, fddi_padding, 3, err)) if (!iptrace_read_rec_data(wth->random_fh, fddi_padding, 3,
err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
} }
/* Get the packet data */ /* Get the packet data */
if (!iptrace_read_rec_data(wth->random_fh, pd, packet_size, err)) if (!iptrace_read_rec_data(wth->random_fh, pd, packet_size, err,
err_info))
return FALSE; return FALSE;
/* Fill in the pseudo_header. */ /* Fill in the pseudo_header. */
@ -302,7 +306,7 @@ typedef struct {
#define IPTRACE_2_0_PDATA_SIZE 32 /* packet data */ #define IPTRACE_2_0_PDATA_SIZE 32 /* packet data */
/* Read the next packet */ /* Read the next packet */
static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_, static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset) gint64 *data_offset)
{ {
int ret; int ret;
@ -315,7 +319,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_,
/* Read the descriptor data */ /* Read the descriptor data */
*data_offset = wth->data_offset; *data_offset = wth->data_offset;
ret = iptrace_read_rec_header(wth->fh, header, IPTRACE_2_0_PHDR_SIZE, ret = iptrace_read_rec_header(wth->fh, header, IPTRACE_2_0_PHDR_SIZE,
err); err, err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
return FALSE; return FALSE;
@ -348,13 +352,15 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_,
/* /*
* Read the padding. * Read the padding.
*/ */
if (!iptrace_read_rec_data(wth->fh, fddi_padding, 3, err)) if (!iptrace_read_rec_data(wth->fh, fddi_padding, 3, err,
err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
} }
buffer_assure_space( wth->frame_buffer, packet_size ); buffer_assure_space( wth->frame_buffer, packet_size );
data_ptr = buffer_start_ptr( wth->frame_buffer ); data_ptr = buffer_start_ptr( wth->frame_buffer );
if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err)) if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err,
err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -392,7 +398,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_,
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off, static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
int ret; int ret;
guint8 header[IPTRACE_2_0_PHDR_SIZE]; guint8 header[IPTRACE_2_0_PHDR_SIZE];
@ -404,7 +410,7 @@ static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
/* Read the descriptor data */ /* Read the descriptor data */
ret = iptrace_read_rec_header(wth->random_fh, header, ret = iptrace_read_rec_header(wth->random_fh, header,
IPTRACE_2_0_PHDR_SIZE, err); IPTRACE_2_0_PHDR_SIZE, err, err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
if (ret == 0) { if (ret == 0) {
@ -427,12 +433,14 @@ static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
/* /*
* Read the padding. * Read the padding.
*/ */
if (!iptrace_read_rec_data(wth->random_fh, fddi_padding, 3, err)) if (!iptrace_read_rec_data(wth->random_fh, fddi_padding, 3,
err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
} }
/* Get the packet data */ /* Get the packet data */
if (!iptrace_read_rec_data(wth->random_fh, pd, packet_size, err)) if (!iptrace_read_rec_data(wth->random_fh, pd, packet_size, err,
err_info))
return FALSE; return FALSE;
/* Fill in the pseudo-header. */ /* Fill in the pseudo-header. */
@ -443,14 +451,15 @@ static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
} }
static int static int
iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len, int *err) iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(header, header_len, fh); bytes_read = file_read(header, header_len, fh);
if (bytes_read != header_len) { if (bytes_read != header_len) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
if (bytes_read != 0) { if (bytes_read != 0) {
@ -463,7 +472,8 @@ iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len, int *err)
} }
static gboolean static gboolean
iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, int packet_size, int *err) iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, int packet_size, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -471,7 +481,7 @@ iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, int packet_size, int *err)
bytes_read = file_read( data_ptr, packet_size, fh ); bytes_read = file_read( data_ptr, packet_size, fh );
if (bytes_read != packet_size) { if (bytes_read != packet_size) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -151,8 +151,9 @@ static gboolean iseries_seek_read (wtap * wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, union wtap_pseudo_header *pseudo_header,
guint8 * pd, int len, int *err, guint8 * pd, int len, int *err,
gchar ** err_info); gchar ** err_info);
static gboolean iseries_check_file_type (wtap * wth, int *err, int format); static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info,
static gint64 iseries_seek_next_packet (wtap * wth, int *err); int format);
static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info);
static int iseries_parse_packet (wtap * wth, FILE_T fh, static int iseries_parse_packet (wtap * wth, FILE_T fh,
union wtap_pseudo_header *pseudo_header, union wtap_pseudo_header *pseudo_header,
guint8 * pd, int *err, gchar ** err_info); guint8 * pd, int *err, gchar ** err_info);
@ -161,7 +162,7 @@ static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf,
int len); int len);
int int
iseries_open (wtap * wth, int *err, gchar ** err_info _U_) iseries_open (wtap * wth, int *err, gchar ** err_info)
{ {
int bytes_read; int bytes_read;
char magic[ISERIES_HDR_MAGIC_LEN]; char magic[ISERIES_HDR_MAGIC_LEN];
@ -179,7 +180,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info _U_)
bytes_read = file_read (&magic, sizeof magic, wth->fh); bytes_read = file_read (&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) if (bytes_read != sizeof magic)
{ {
*err = file_error (wth->fh); *err = file_error (wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -196,7 +197,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info _U_)
* Do some basic sanity checking to ensure we can handle the * Do some basic sanity checking to ensure we can handle the
* contents of this trace * contents of this trace
*/ */
if (!iseries_check_file_type (wth, err, ISERIES_FORMAT_ASCII)) if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_ASCII))
{ {
if (*err == 0) if (*err == 0)
return 0; return 0;
@ -228,7 +229,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info _U_)
* Do some basic sanity checking to ensure we can handle the * Do some basic sanity checking to ensure we can handle the
* contents of this trace * contents of this trace
*/ */
if (!iseries_check_file_type (wth, err, ISERIES_FORMAT_UNICODE)) if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_UNICODE))
{ {
if (*err == 0) if (*err == 0)
return 0; return 0;
@ -259,7 +260,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info _U_)
* requisit requirements and additional information. * requisit requirements and additional information.
*/ */
static gboolean static gboolean
iseries_check_file_type (wtap * wth, int *err, int format) iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format)
{ {
guint line; guint line;
int num_items_scanned; int num_items_scanned;
@ -332,7 +333,7 @@ iseries_check_file_type (wtap * wth, int *err, int format)
if (file_eof (wth->fh)) if (file_eof (wth->fh))
*err = 0; *err = 0;
else else
*err = file_error (wth->fh); *err = file_error (wth->fh, err_info);
return FALSE; return FALSE;
} }
} }
@ -352,7 +353,7 @@ iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset)
/* /*
* Locate the next packet * Locate the next packet
*/ */
offset = iseries_seek_next_packet (wth, err); offset = iseries_seek_next_packet (wth, err, err_info);
if (offset < 1) if (offset < 1)
return FALSE; return FALSE;
@ -372,10 +373,11 @@ iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset)
/* /*
* Seeks to the beginning of the next packet, and returns the * Seeks to the beginning of the next packet, and returns the
* byte offset. Returns -1 on failure, and sets "*err" to the error. * byte offset. Returns -1 on failure, and sets "*err" to the error
* and "*err_info" to null or an additional error string.
*/ */
static gint64 static gint64
iseries_seek_next_packet (wtap * wth, int *err) iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info)
{ {
iseries_t *iseries = (iseries_t *)wth->priv; iseries_t *iseries = (iseries_t *)wth->priv;
char buf[ISERIES_LINE_LENGTH]; char buf[ISERIES_LINE_LENGTH];
@ -385,7 +387,8 @@ iseries_seek_next_packet (wtap * wth, int *err)
/* /*
* Seeks to the beginning of the next packet, and returns the * Seeks to the beginning of the next packet, and returns the
* byte offset. Returns -1 on failure, and sets "*err" to the error. * byte offset. Returns -1 on failure, and sets "*err" to the error
* and "*err_info" to null or an additional error string.
*/ */
for (line = 0; line < ISERIES_MAX_TRACE_LEN; line++) for (line = 0; line < ISERIES_MAX_TRACE_LEN; line++)
{ {
@ -412,7 +415,7 @@ iseries_seek_next_packet (wtap * wth, int *err)
cur_off = file_tell (wth->fh); cur_off = file_tell (wth->fh);
if (cur_off == -1) if (cur_off == -1)
{ {
*err = file_error (wth->fh); *err = file_error (wth->fh, err_info);
return -1; return -1;
} }
if (file_seek (wth->fh, cur_off - buflen, SEEK_SET, err) == -1) if (file_seek (wth->fh, cur_off - buflen, SEEK_SET, err) == -1)
@ -433,7 +436,7 @@ iseries_seek_next_packet (wtap * wth, int *err)
else else
{ {
/* We got an error. */ /* We got an error. */
*err = file_error (wth->fh); *err = file_error (wth->fh, err_info);
} }
return -1; return -1;
} }
@ -508,7 +511,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh,
cur_off = file_tell (fh); cur_off = file_tell (fh);
if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL) if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL)
{ {
*err = file_error (fh); *err = file_error (fh, err_info);
if (*err == 0) if (*err == 0)
{ {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -614,7 +617,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh,
} }
else else
{ {
*err = file_error (fh); *err = file_error (fh, err_info);
if (*err == 0) if (*err == 0)
{ {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -698,7 +701,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh,
if (cur_off == -1) if (cur_off == -1)
{ {
/* Error. */ /* Error. */
*err = file_error (fh); *err = file_error (fh, err_info);
return -1; return -1;
} }
if (file_seek (fh, cur_off - buflen, SEEK_SET, err) == -1) if (file_seek (fh, cur_off - buflen, SEEK_SET, err) == -1)

View File

@ -83,7 +83,7 @@ jpeg_jfif_read(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
buf = buffer_start_ptr(wth->frame_buffer); buf = buffer_start_ptr(wth->frame_buffer);
wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err); wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info);
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -116,7 +116,8 @@ jpeg_jfif_seek_read(wtap *wth, gint64 seek_off,
return FALSE; return FALSE;
} }
wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err); wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err,
err_info);
*err = 0; *err = 0;
*err_info = NULL; *err_info = NULL;
@ -133,7 +134,7 @@ jpeg_jfif_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic_buf, sizeof(magic_buf), wth->fh); bytes_read = file_read(magic_buf, sizeof(magic_buf), wth->fh);
if (bytes_read != (int) sizeof(magic_buf)) { if (bytes_read != (int) sizeof(magic_buf)) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) { if (*err != 0) {
*err_info = NULL; *err_info = NULL;
ret = -1; ret = -1;

View File

@ -301,7 +301,7 @@ static gint get_record(guint8** bufferp, FILE_T fh, gint64 file_offset,
return 0; return 0;
} else if ( bytes_read < 0x14 ){ } else if ( bytes_read < 0x14 ){
K12_DBG(1,("get_record: SHORT READ OR ERROR")); K12_DBG(1,("get_record: SHORT READ OR ERROR"));
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -318,7 +318,7 @@ static gint get_record(guint8** bufferp, FILE_T fh, gint64 file_offset,
return 0; return 0;
} else if ( bytes_read != 0x4 ) { } else if ( bytes_read != 0x4 ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR")); K12_DBG(1,("get_record: SHORT READ OR ERROR"));
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -355,7 +355,7 @@ static gint get_record(guint8** bufferp, FILE_T fh, gint64 file_offset,
if ( last_read != left ) { if ( last_read != left ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR")); K12_DBG(1,("get_record: SHORT READ OR ERROR"));
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -369,7 +369,7 @@ static gint get_record(guint8** bufferp, FILE_T fh, gint64 file_offset,
if ( last_read != junky_offset ) { if ( last_read != junky_offset ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR, read=%d expected=%d",last_read, junky_offset)); K12_DBG(1,("get_record: SHORT READ OR ERROR, read=%d expected=%d",last_read, junky_offset));
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -382,7 +382,7 @@ static gint get_record(guint8** bufferp, FILE_T fh, gint64 file_offset,
if ( last_read != 0x10 ) { if ( last_read != 0x10 ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR")); K12_DBG(1,("get_record: SHORT READ OR ERROR"));
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -691,7 +691,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
if ( file_read(header_buffer,0x200,wth->fh) != 0x200 ) { if ( file_read(header_buffer,0x200,wth->fh) != 0x200 ) {
K12_DBG(1,("k12_open: FILE HEADER TOO SHORT OR READ ERROR")); K12_DBG(1,("k12_open: FILE HEADER TOO SHORT OR READ ERROR"));
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) { if (*err != 0) {
return -1; return -1;
} }

View File

@ -145,7 +145,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(LE_record_type, 2, wth->fh); bytes_read = file_read(LE_record_type, 2, wth->fh);
bytes_read += file_read(LE_record_length, 2, wth->fh); bytes_read += file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 4) { if (bytes_read != 4) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -180,7 +180,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(LE_record_type, 2, wth->fh); bytes_read = file_read(LE_record_type, 2, wth->fh);
bytes_read += file_read(LE_record_length, 2, wth->fh); bytes_read += file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 4) { if (bytes_read != 4) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) { if (*err != 0) {
g_free(wth->priv); g_free(wth->priv);
return -1; return -1;
@ -201,7 +201,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(summary, sizeof summary, bytes_read = file_read(summary, sizeof summary,
wth->fh); wth->fh);
if (bytes_read != sizeof summary) { if (bytes_read != sizeof summary) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) { if (*err != 0) {
g_free(wth->priv); g_free(wth->priv);
return -1; return -1;
@ -295,7 +295,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(LE_record_type, 2, wth->fh); bytes_read = file_read(LE_record_type, 2, wth->fh);
if (bytes_read != 2) { if (bytes_read != 2) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) { if (*err == 0 && bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -304,7 +304,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
wth->data_offset += 2; wth->data_offset += 2;
bytes_read = file_read(LE_record_length, 2, wth->fh); bytes_read = file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 2) { if (bytes_read != 2) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -331,7 +331,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(descriptor, DESCRIPTOR_LEN, wth->fh); bytes_read = file_read(descriptor, DESCRIPTOR_LEN, wth->fh);
if (bytes_read != DESCRIPTOR_LEN) { if (bytes_read != DESCRIPTOR_LEN) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -346,7 +346,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
packet_size, wth->fh); packet_size, wth->fh);
if (bytes_read != packet_size) { if (bytes_read != packet_size) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -404,7 +404,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off, static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -416,7 +416,7 @@ static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
*/ */
bytes_read = file_read(pd, length, wth->random_fh); bytes_read = file_read(pd, length, wth->random_fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -76,7 +76,7 @@ static int libpcap_read_header(wtap *wth, int *err, gchar **err_info,
struct pcaprec_ss990915_hdr *hdr); struct pcaprec_ss990915_hdr *hdr);
static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr); static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr);
static gboolean libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, static gboolean libpcap_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err); int *err, gchar **err_info);
static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err); const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
@ -95,7 +95,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&magic, sizeof magic, wth->fh); bytes_read = file_read(&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) { if (bytes_read != sizeof magic) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -166,7 +166,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, wth->fh); bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) { if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -635,7 +635,8 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
/* /*
* Read the padding. * Read the padding.
*/ */
if (!libpcap_read_rec_data(wth->fh, fddi_padding, 3, err)) if (!libpcap_read_rec_data(wth->fh, fddi_padding, 3, err,
err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
} }
@ -657,7 +658,7 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
if (!libpcap_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), if (!libpcap_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
packet_size, err)) packet_size, err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -723,7 +724,7 @@ libpcap_seek_read(wtap *wth, gint64 seek_off,
/* /*
* Read the packet data. * Read the packet data.
*/ */
if (!libpcap_read_rec_data(wth->random_fh, pd, length, err)) if (!libpcap_read_rec_data(wth->random_fh, pd, length, err, err_info))
return FALSE; /* failed */ return FALSE; /* failed */
if (wth->file_encap == WTAP_ENCAP_ATM_PDUS) { if (wth->file_encap == WTAP_ENCAP_ATM_PDUS) {
@ -789,7 +790,7 @@ static int libpcap_read_header(wtap *wth, int *err, gchar **err_info,
} }
bytes_read = file_read(hdr, bytes_to_read, wth->fh); bytes_read = file_read(hdr, bytes_to_read, wth->fh);
if (bytes_read != bytes_to_read) { if (bytes_read != bytes_to_read) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) { if (*err == 0 && bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -875,7 +876,8 @@ adjust_header(wtap *wth, struct pcaprec_hdr *hdr)
} }
static gboolean static gboolean
libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -883,7 +885,7 @@ libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
bytes_read = file_read(pd, length, fh); bytes_read = file_read(pd, length, fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -75,15 +75,14 @@ mpeg_resync(wtap *wth, int *err, gchar **err_info _U_)
} }
static int static int
mpeg_read_header(wtap *wth, int *err, gchar **err_info _U_, mpeg_read_header(wtap *wth, int *err, gchar **err_info, guint32 *n)
guint32 *n)
{ {
int bytes_read; int bytes_read;
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(n, sizeof *n, wth->fh); bytes_read = file_read(n, sizeof *n, wth->fh);
if (bytes_read != sizeof *n) { if (bytes_read != sizeof *n) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -95,7 +94,8 @@ mpeg_read_header(wtap *wth, int *err, gchar **err_info _U_,
} }
static gboolean static gboolean
mpeg_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) mpeg_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -103,7 +103,7 @@ mpeg_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
bytes_read = file_read(pd, length, fh); bytes_read = file_read(pd, length, fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -114,8 +114,7 @@ mpeg_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
#define SCRHZ 27000000 #define SCRHZ 27000000
static gboolean static gboolean
mpeg_read(wtap *wth, int *err, gchar **err_info _U_, mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
gint64 *data_offset)
{ {
mpeg_t *mpeg = (mpeg_t *)wth->priv; mpeg_t *mpeg = (mpeg_t *)wth->priv;
guint32 n; guint32 n;
@ -136,7 +135,7 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
bytes_read = file_read(&stream, sizeof stream, wth->fh); bytes_read = file_read(&stream, sizeof stream, wth->fh);
if (bytes_read != sizeof stream) { if (bytes_read != sizeof stream) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; return FALSE;
} }
@ -148,14 +147,14 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
bytes_read = file_read(&pack1, sizeof pack1, wth->fh); bytes_read = file_read(&pack1, sizeof pack1, wth->fh);
if (bytes_read != sizeof pack1) { if (bytes_read != sizeof pack1) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
} }
bytes_read = file_read(&pack0, sizeof pack0, wth->fh); bytes_read = file_read(&pack0, sizeof pack0, wth->fh);
if (bytes_read != sizeof pack0) { if (bytes_read != sizeof pack0) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -169,7 +168,7 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
bytes_read = file_read(&stuffing, bytes_read = file_read(&stuffing,
sizeof stuffing, wth->fh); sizeof stuffing, wth->fh);
if (bytes_read != sizeof stuffing) { if (bytes_read != sizeof stuffing) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; return FALSE;
} }
stuffing &= 0x07; stuffing &= 0x07;
@ -198,7 +197,7 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
guint16 length; guint16 length;
bytes_read = file_read(&length, sizeof length, wth->fh); bytes_read = file_read(&length, sizeof length, wth->fh);
if (bytes_read != sizeof length) { if (bytes_read != sizeof length) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -230,7 +229,7 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
if (!mpeg_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), if (!mpeg_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
packet_size, err)) packet_size, err, err_info))
return FALSE; return FALSE;
wth->data_offset += packet_size; wth->data_offset += packet_size;
wth->phdr.ts = ts; wth->phdr.ts = ts;
@ -242,11 +241,11 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
static gboolean static gboolean
mpeg_seek_read(wtap *wth, gint64 seek_off, mpeg_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header _U_, guchar *pd, int length, union wtap_pseudo_header *pseudo_header _U_, guchar *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE; return FALSE;
return mpeg_read_rec_data(wth->random_fh, pd, length, err); return mpeg_read_rec_data(wth->random_fh, pd, length, err, err_info);
} }
struct _mpeg_magic { struct _mpeg_magic {
@ -261,7 +260,7 @@ struct _mpeg_magic {
}; };
int int
mpeg_open(wtap *wth, int *err, gchar **err_info _U_) mpeg_open(wtap *wth, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
char magic_buf[16]; char magic_buf[16];
@ -271,7 +270,7 @@ mpeg_open(wtap *wth, int *err, gchar **err_info _U_)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic_buf, sizeof magic_buf, wth->fh); bytes_read = file_read(magic_buf, sizeof magic_buf, wth->fh);
if (bytes_read != (int) sizeof magic_buf) { if (bytes_read != (int) sizeof magic_buf) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;

View File

@ -179,9 +179,9 @@ static gboolean netmon_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info); int *err, gchar **err_info);
static gboolean netmon_read_atm_pseudoheader(FILE_T fh, static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err); union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
static gboolean netmon_read_rec_data(FILE_T fh, guchar *pd, int length, static gboolean netmon_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err); int *err, gchar **err_info);
static void netmon_sequential_close(wtap *wth); static void netmon_sequential_close(wtap *wth);
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err); const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
@ -208,7 +208,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, sizeof magic, wth->fh); bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) { if (bytes_read != sizeof magic) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -223,7 +223,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, wth->fh); bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) { if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -341,7 +341,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(frame_table, frame_table_length, wth->fh); bytes_read = file_read(frame_table, frame_table_length, wth->fh);
if ((guint32)bytes_read != frame_table_length) { if ((guint32)bytes_read != frame_table_length) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
g_free(frame_table); g_free(frame_table);
@ -437,7 +437,7 @@ again:
bytes_read = file_read(&hdr, hdr_size, wth->fh); bytes_read = file_read(&hdr, hdr_size, wth->fh);
if (bytes_read != hdr_size) { if (bytes_read != hdr_size) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) { if (*err == 0 && bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -491,7 +491,7 @@ again:
return FALSE; return FALSE;
} }
if (!netmon_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, if (!netmon_read_atm_pseudoheader(wth->fh, &wth->pseudo_header,
err)) err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
/* /*
@ -512,7 +512,8 @@ again:
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
data_ptr = buffer_start_ptr(wth->frame_buffer); data_ptr = buffer_start_ptr(wth->frame_buffer);
if (!netmon_read_rec_data(wth->fh, data_ptr, packet_size, err)) if (!netmon_read_rec_data(wth->fh, data_ptr, packet_size, err,
err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -586,7 +587,7 @@ again:
bytes_read = file_read(&trlr, trlr_size, wth->fh); bytes_read = file_read(&trlr, trlr_size, wth->fh);
if (bytes_read != trlr_size) { if (bytes_read != trlr_size) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) { if (*err == 0 && bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -653,7 +654,7 @@ again:
static gboolean static gboolean
netmon_seek_read(wtap *wth, gint64 seek_off, netmon_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE; return FALSE;
@ -662,7 +663,7 @@ netmon_seek_read(wtap *wth, gint64 seek_off,
case WTAP_ENCAP_ATM_PDUS: case WTAP_ENCAP_ATM_PDUS:
if (!netmon_read_atm_pseudoheader(wth->random_fh, pseudo_header, if (!netmon_read_atm_pseudoheader(wth->random_fh, pseudo_header,
err)) { err, err_info)) {
/* Read error */ /* Read error */
return FALSE; return FALSE;
} }
@ -679,7 +680,7 @@ netmon_seek_read(wtap *wth, gint64 seek_off,
/* /*
* Read the packet data. * Read the packet data.
*/ */
if (!netmon_read_rec_data(wth->random_fh, pd, length, err)) if (!netmon_read_rec_data(wth->random_fh, pd, length, err, err_info))
return FALSE; return FALSE;
/* /*
@ -694,7 +695,7 @@ netmon_seek_read(wtap *wth, gint64 seek_off,
static gboolean static gboolean
netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
int *err) int *err, gchar **err_info)
{ {
struct netmon_atm_hdr atm_phdr; struct netmon_atm_hdr atm_phdr;
int bytes_read; int bytes_read;
@ -703,7 +704,7 @@ netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&atm_phdr, sizeof (struct netmon_atm_hdr), fh); bytes_read = file_read(&atm_phdr, sizeof (struct netmon_atm_hdr), fh);
if (bytes_read != sizeof (struct netmon_atm_hdr)) { if (bytes_read != sizeof (struct netmon_atm_hdr)) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -727,7 +728,8 @@ netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
} }
static gboolean static gboolean
netmon_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) netmon_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -735,7 +737,7 @@ netmon_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
bytes_read = file_read(pd, length, fh); bytes_read = file_read(pd, length, fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -415,7 +415,7 @@ gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info,
gboolean nstrace_seek_read(wtap *wth, gint64 seek_off, gboolean nstrace_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, union wtap_pseudo_header *pseudo_header,
guchar *pd, int length, guchar *pd, int length,
int *err, gchar **err_info _U_); int *err, gchar **err_info);
void nstrace_close(wtap *wth); void nstrace_close(wtap *wth);
void nstrace_sequential_close(wtap *wth); void nstrace_sequential_close(wtap *wth);
@ -483,7 +483,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1) if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
g_free(nstrace_buf); g_free(nstrace_buf);
return 0; return 0;
} }
@ -491,7 +491,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(nstrace_buf, page_size, wth->fh); bytes_read = file_read(nstrace_buf, page_size, wth->fh);
if (bytes_read != page_size) if (bytes_read != page_size)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
g_free(nstrace_buf); g_free(nstrace_buf);
return 0; return 0;
} }
@ -518,7 +518,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
/* Reset the read pointer to start of the file. */ /* Reset the read pointer to start of the file. */
if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1) if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
g_free(nstrace->pnstrace_buf); g_free(nstrace->pnstrace_buf);
g_free(nstrace); g_free(nstrace);
return 0; return 0;
@ -528,7 +528,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(nstrace_buf, page_size, wth->fh); bytes_read = file_read(nstrace_buf, page_size, wth->fh);
if (bytes_read != page_size) if (bytes_read != page_size)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
g_free(nstrace->pnstrace_buf); g_free(nstrace->pnstrace_buf);
g_free(nstrace); g_free(nstrace);
return 0; return 0;
@ -953,7 +953,7 @@ gboolean nstrace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset
gboolean nstrace_seek_read(wtap *wth, gint64 seek_off, gboolean nstrace_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -966,8 +966,12 @@ gboolean nstrace_seek_read(wtap *wth, gint64 seek_off,
** Read the packet data. ** Read the packet data.
*/ */
bytes_read = file_read(pd, length, wth->random_fh); bytes_read = file_read(pd, length, wth->random_fh);
if (bytes_read != length) if (bytes_read != length) {
*err = file_error(wth->random_fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
}
if (wth->file_type == WTAP_FILE_NETSCALER_1_0) if (wth->file_type == WTAP_FILE_NETSCALER_1_0)
{ {

View File

@ -58,8 +58,10 @@
static gboolean empty_line(const gchar *line); static gboolean empty_line(const gchar *line);
static gboolean info_line(const gchar *line); static gboolean info_line(const gchar *line);
static gint64 netscreen_seek_next_packet(wtap *wth, int *err, char *hdr); static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info,
static gboolean netscreen_check_file_type(wtap *wth, int *err); char *hdr);
static gboolean netscreen_check_file_type(wtap *wth, int *err,
gchar **err_info);
static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info, static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset); gint64 *data_offset);
static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off, static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off,
@ -110,8 +112,10 @@ static gboolean info_line(const gchar *line)
/* Seeks to the beginning of the next packet, and returns the /* Seeks to the beginning of the next packet, and returns the
byte offset. Copy the header line to hdr. Returns -1 on failure, byte offset. Copy the header line to hdr. Returns -1 on failure,
and sets "*err" to the error and set hdr as NULL. */ and sets "*err" to the error, sets "*err_info" to null or an
static gint64 netscreen_seek_next_packet(wtap *wth, int *err, char *hdr) additional error string, and sets hdr to NULL. */
static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info,
char *hdr)
{ {
gint64 cur_off; gint64 cur_off;
char buf[NETSCREEN_LINE_LENGTH]; char buf[NETSCREEN_LINE_LENGTH];
@ -120,7 +124,7 @@ static gint64 netscreen_seek_next_packet(wtap *wth, int *err, char *hdr)
cur_off = file_tell(wth->fh); cur_off = file_tell(wth->fh);
if (cur_off == -1) { if (cur_off == -1) {
/* Error */ /* Error */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
hdr = NULL; hdr = NULL;
return -1; return -1;
} }
@ -136,7 +140,7 @@ static gint64 netscreen_seek_next_packet(wtap *wth, int *err, char *hdr)
*err = 0; *err = 0;
} else { } else {
/* We got an error. */ /* We got an error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
} }
break; break;
} }
@ -149,9 +153,10 @@ static gint64 netscreen_seek_next_packet(wtap *wth, int *err, char *hdr)
* NetScreen snoop output. * NetScreen snoop output.
* *
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error; * Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
* if we get an I/O error, "*err" will be set to a non-zero value. * if we get an I/O error, "*err" will be set to a non-zero value and
* "*err_info" is set to null or an additional error string.
*/ */
static gboolean netscreen_check_file_type(wtap *wth, int *err) static gboolean netscreen_check_file_type(wtap *wth, int *err, gchar **err_info)
{ {
char buf[NETSCREEN_LINE_LENGTH]; char buf[NETSCREEN_LINE_LENGTH];
guint reclen, line; guint reclen, line;
@ -176,7 +181,7 @@ static gboolean netscreen_check_file_type(wtap *wth, int *err)
if (file_eof(wth->fh)) if (file_eof(wth->fh))
*err = 0; *err = 0;
else else
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; return FALSE;
} }
} }
@ -185,11 +190,11 @@ static gboolean netscreen_check_file_type(wtap *wth, int *err)
} }
int netscreen_open(wtap *wth, int *err, gchar **err_info _U_) int netscreen_open(wtap *wth, int *err, gchar **err_info)
{ {
/* Look for a NetScreen snoop header line */ /* Look for a NetScreen snoop header line */
if (!netscreen_check_file_type(wth, err)) { if (!netscreen_check_file_type(wth, err, err_info)) {
if (*err == 0) if (*err == 0)
return 0; return 0;
else else
@ -224,7 +229,7 @@ static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
gchar dststr[13]; gchar dststr[13];
/* Find the next packet */ /* Find the next packet */
offset = netscreen_seek_next_packet(wth, err, line); offset = netscreen_seek_next_packet(wth, err, err_info, line);
if (offset < 0) if (offset < 0)
return FALSE; return FALSE;
@ -307,7 +312,7 @@ netscreen_seek_read (wtap *wth, gint64 seek_off,
} }
if (file_gets(line, NETSCREEN_LINE_LENGTH, wth->random_fh) == NULL) { if (file_gets(line, NETSCREEN_LINE_LENGTH, wth->random_fh) == NULL) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }

View File

@ -188,11 +188,11 @@ static int nettl_read_rec_header(wtap *wth, FILE_T fh,
struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header, struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header,
int *err, gchar **err_info, gboolean *fddihack); int *err, gchar **err_info, gboolean *fddihack);
static gboolean nettl_read_rec_data(FILE_T fh, guchar *pd, int length, static gboolean nettl_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err, gboolean fddihack); int *err, gchar **err_info, gboolean fddihack);
static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err); const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
int nettl_open(wtap *wth, int *err, gchar **err_info _U_) int nettl_open(wtap *wth, int *err, gchar **err_info)
{ {
struct nettl_file_hdr file_hdr; struct nettl_file_hdr file_hdr;
guint16 dummy[2]; guint16 dummy[2];
@ -206,7 +206,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(file_hdr.magic, MAGIC_SIZE, wth->fh); bytes_read = file_read(file_hdr.magic, MAGIC_SIZE, wth->fh);
if (bytes_read != MAGIC_SIZE) { if (bytes_read != MAGIC_SIZE) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -221,7 +221,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
bytes_read = file_read(file_hdr.file_name, FILE_HDR_SIZE - MAGIC_SIZE, bytes_read = file_read(file_hdr.file_name, FILE_HDR_SIZE - MAGIC_SIZE,
wth->fh); wth->fh);
if (bytes_read != FILE_HDR_SIZE - MAGIC_SIZE) { if (bytes_read != FILE_HDR_SIZE - MAGIC_SIZE) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -338,7 +338,7 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
*/ */
buffer_assure_space(wth->frame_buffer, wth->phdr.caplen); buffer_assure_space(wth->frame_buffer, wth->phdr.caplen);
if (!nettl_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), if (!nettl_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
wth->phdr.caplen, err, fddihack)) wth->phdr.caplen, err, err_info, fddihack))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += wth->phdr.caplen; wth->data_offset += wth->phdr.caplen;
return TRUE; return TRUE;
@ -371,7 +371,8 @@ nettl_seek_read(wtap *wth, gint64 seek_off,
/* /*
* Read the packet data. * Read the packet data.
*/ */
return nettl_read_rec_data(wth->random_fh, pd, length, err, fddihack); return nettl_read_rec_data(wth->random_fh, pd, length, err, err_info,
fddihack);
} }
static int static int
@ -393,7 +394,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&rec_hdr.hdr_len, sizeof rec_hdr.hdr_len, fh); bytes_read = file_read(&rec_hdr.hdr_len, sizeof rec_hdr.hdr_len, fh);
if (bytes_read != sizeof rec_hdr.hdr_len) { if (bytes_read != sizeof rec_hdr.hdr_len) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
if (bytes_read != 0) { if (bytes_read != 0) {
@ -412,7 +413,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
} }
bytes_read = file_read(&rec_hdr.subsys, NETTL_REC_HDR_LEN - 2, fh); bytes_read = file_read(&rec_hdr.subsys, NETTL_REC_HDR_LEN - 2, fh);
if (bytes_read != NETTL_REC_HDR_LEN - 2) { if (bytes_read != NETTL_REC_HDR_LEN - 2) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -506,7 +507,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
/* outbound appears to have variable padding */ /* outbound appears to have variable padding */
bytes_read = file_read(dummyc, 9, fh); bytes_read = file_read(dummyc, 9, fh);
if (bytes_read != 9) { if (bytes_read != 9) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -559,7 +560,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
phdr->pkt_encap = WTAP_ENCAP_NETTL_ETHERNET; phdr->pkt_encap = WTAP_ENCAP_NETTL_ETHERNET;
bytes_read = file_read(&drv_eth_hdr, NS_LS_DRV_ETH_HDR_LEN, fh); bytes_read = file_read(&drv_eth_hdr, NS_LS_DRV_ETH_HDR_LEN, fh);
if (bytes_read != NS_LS_DRV_ETH_HDR_LEN) { if (bytes_read != NS_LS_DRV_ETH_HDR_LEN) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -649,7 +650,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
} }
static gboolean static gboolean
nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, gboolean fddihack) nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info, gboolean fddihack)
{ {
int bytes_read; int bytes_read;
guchar *p=NULL; guchar *p=NULL;
@ -679,7 +681,7 @@ nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, gboolean fddiha
bytes_read = file_read(pd, length, fh); bytes_read = file_read(pd, length, fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -118,7 +118,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
/* read in the buffer file header */ /* read in the buffer file header */
bytes_read = file_read(&file_header, sizeof file_header, wth->fh); bytes_read = file_read(&file_header, sizeof file_header, wth->fh);
if (bytes_read != sizeof file_header) { if (bytes_read != sizeof file_header) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -142,7 +142,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
/* read the TLV header */ /* read the TLV header */
bytes_read = file_read(&tlvh, sizeof tlvh, wth->fh); bytes_read = file_read(&tlvh, sizeof tlvh, wth->fh);
if (bytes_read != sizeof tlvh) { if (bytes_read != sizeof tlvh) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -184,7 +184,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
/* pull off the packet header */ /* pull off the packet header */
bytes_read = file_read(&packet_header, sizeof packet_header, wth->fh); bytes_read = file_read(&packet_header, sizeof packet_header, wth->fh);
if (bytes_read != sizeof packet_header) { if (bytes_read != sizeof packet_header) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -348,7 +348,7 @@ read_packet_header(FILE_T fh, packet_entry_header *packet_header, int *err,
/* pull off the packet header */ /* pull off the packet header */
bytes_read = file_read(packet_header, sizeof *packet_header, fh); bytes_read = file_read(packet_header, sizeof *packet_header, fh);
if (bytes_read != sizeof *packet_header) { if (bytes_read != sizeof *packet_header) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; /* EOF */ return 0; /* EOF */
@ -398,7 +398,7 @@ read_packet_header(FILE_T fh, packet_entry_header *packet_header, int *err,
/* read the TLV header */ /* read the TLV header */
bytes_read = file_read(&tlvh, sizeof tlvh, fh); bytes_read = file_read(&tlvh, sizeof tlvh, fh);
if (bytes_read != sizeof tlvh) { if (bytes_read != sizeof tlvh) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -445,7 +445,7 @@ read_packet_data(FILE_T fh, int offset_to_frame, int offset, guint8 *pd,
} }
/* read in the packet */ /* read in the packet */
wtap_file_read_expected_bytes(pd, length, fh, err); wtap_file_read_expected_bytes(pd, length, fh, err, err_info);
return TRUE; return TRUE;
} }

View File

@ -325,11 +325,11 @@ static gboolean netxray_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info); int *err, gchar **err_info);
static int netxray_read_rec_header(wtap *wth, FILE_T fh, static int netxray_read_rec_header(wtap *wth, FILE_T fh,
union netxrayrec_hdr *hdr, int *err); union netxrayrec_hdr *hdr, int *err, gchar **err_info);
static guint netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len, static guint netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
union wtap_pseudo_header *pseudo_header, union netxrayrec_hdr *hdr); union wtap_pseudo_header *pseudo_header, union netxrayrec_hdr *hdr);
static gboolean netxray_read_rec_data(FILE_T fh, guint8 *data_ptr, static gboolean netxray_read_rec_data(FILE_T fh, guint8 *data_ptr,
guint32 packet_size, int *err); guint32 packet_size, int *err, gchar **err_info);
static gboolean netxray_dump_1_1(wtap_dumper *wdh, static gboolean netxray_dump_1_1(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err); const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
@ -383,7 +383,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, sizeof magic, wth->fh); bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) { if (bytes_read != sizeof magic) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -402,7 +402,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, wth->fh); bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) { if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -912,7 +912,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
} }
/* Read the next packet */ /* Read the next packet */
static gboolean netxray_read(wtap *wth, int *err, gchar **err_info _U_, static gboolean netxray_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset) gint64 *data_offset)
{ {
netxray_t *netxray = (netxray_t *)wth->priv; netxray_t *netxray = (netxray_t *)wth->priv;
@ -931,7 +931,7 @@ reread:
return FALSE; return FALSE;
} }
/* Read record header. */ /* Read record header. */
hdr_size = netxray_read_rec_header(wth, wth->fh, &hdr, err); hdr_size = netxray_read_rec_header(wth, wth->fh, &hdr, err, err_info);
if (hdr_size == 0) { if (hdr_size == 0) {
/* /*
* Error or EOF. * Error or EOF.
@ -998,7 +998,7 @@ reread:
packet_size = pletohs(&hdr.hdr_1_x.incl_len); packet_size = pletohs(&hdr.hdr_1_x.incl_len);
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
pd = buffer_start_ptr(wth->frame_buffer); pd = buffer_start_ptr(wth->frame_buffer);
if (!netxray_read_rec_data(wth->fh, pd, packet_size, err)) if (!netxray_read_rec_data(wth->fh, pd, packet_size, err, err_info))
return FALSE; return FALSE;
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -1044,7 +1044,7 @@ reread:
static gboolean static gboolean
netxray_seek_read(wtap *wth, gint64 seek_off, netxray_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
union netxrayrec_hdr hdr; union netxrayrec_hdr hdr;
gboolean ret; gboolean ret;
@ -1052,7 +1052,8 @@ netxray_seek_read(wtap *wth, gint64 seek_off,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE; return FALSE;
if (!netxray_read_rec_header(wth, wth->random_fh, &hdr, err)) { if (!netxray_read_rec_header(wth, wth->random_fh, &hdr, err,
err_info)) {
if (*err == 0) { if (*err == 0) {
/* /*
* EOF - we report that as a short read, as * EOF - we report that as a short read, as
@ -1067,7 +1068,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off,
/* /*
* Read the packet data. * Read the packet data.
*/ */
ret = netxray_read_rec_data(wth->random_fh, pd, length, err); ret = netxray_read_rec_data(wth->random_fh, pd, length, err, err_info);
if (!ret) if (!ret)
return FALSE; return FALSE;
@ -1080,7 +1081,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off,
static int static int
netxray_read_rec_header(wtap *wth, FILE_T fh, union netxrayrec_hdr *hdr, netxray_read_rec_header(wtap *wth, FILE_T fh, union netxrayrec_hdr *hdr,
int *err) int *err, gchar **err_info)
{ {
netxray_t *netxray = (netxray_t *)wth->priv; netxray_t *netxray = (netxray_t *)wth->priv;
int bytes_read; int bytes_read;
@ -1104,7 +1105,7 @@ netxray_read_rec_header(wtap *wth, FILE_T fh, union netxrayrec_hdr *hdr,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(hdr, hdr_size, fh); bytes_read = file_read(hdr, hdr_size, fh);
if (bytes_read != hdr_size) { if (bytes_read != hdr_size) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return 0; return 0;
if (bytes_read != 0) { if (bytes_read != 0) {
@ -1446,7 +1447,7 @@ netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
static gboolean static gboolean
netxray_read_rec_data(FILE_T fh, guint8 *data_ptr, guint32 packet_size, netxray_read_rec_data(FILE_T fh, guint8 *data_ptr, guint32 packet_size,
int *err) int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -1454,7 +1455,7 @@ netxray_read_rec_data(FILE_T fh, guint8 *data_ptr, guint32 packet_size,
bytes_read = file_read(data_ptr, packet_size, fh); bytes_read = file_read(data_ptr, packet_size, fh);
if (bytes_read <= 0 || (guint32)bytes_read != packet_size) { if (bytes_read <= 0 || (guint32)bytes_read != packet_size) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -493,21 +493,21 @@ static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err, gchar **err_info); int *err, gchar **err_info);
static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random, static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random,
guint16 *typep, guint16 *lengthp, int *err); guint16 *typep, guint16 *lengthp, int *err, gchar **err_info);
static gboolean ngsniffer_read_frame2(wtap *wth, gboolean is_random, static gboolean ngsniffer_read_frame2(wtap *wth, gboolean is_random,
struct frame2_rec *frame2, int *err); struct frame2_rec *frame2, int *err, gchar **err_info);
static void set_pseudo_header_frame2(wtap *wth, static void set_pseudo_header_frame2(wtap *wth,
union wtap_pseudo_header *pseudo_header, struct frame2_rec *frame2); union wtap_pseudo_header *pseudo_header, struct frame2_rec *frame2);
static gboolean ngsniffer_read_frame4(wtap *wth, gboolean is_random, static gboolean ngsniffer_read_frame4(wtap *wth, gboolean is_random,
struct frame4_rec *frame4, int *err); struct frame4_rec *frame4, int *err, gchar **err_info);
static void set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header, static void set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header,
struct frame4_rec *frame4); struct frame4_rec *frame4);
static gboolean ngsniffer_read_frame6(wtap *wth, gboolean is_random, static gboolean ngsniffer_read_frame6(wtap *wth, gboolean is_random,
struct frame6_rec *frame6, int *err); struct frame6_rec *frame6, int *err, gchar **err_info);
static void set_pseudo_header_frame6(wtap *wth, static void set_pseudo_header_frame6(wtap *wth,
union wtap_pseudo_header *pseudo_header, struct frame6_rec *frame6); union wtap_pseudo_header *pseudo_header, struct frame6_rec *frame6);
static gboolean ngsniffer_read_rec_data(wtap *wth, gboolean is_random, static gboolean ngsniffer_read_rec_data(wtap *wth, gboolean is_random,
guchar *pd, unsigned int length, int *err); guchar *pd, unsigned int length, int *err, gchar **err_info);
static int infer_pkt_encap(const guint8 *pd, int len); static int infer_pkt_encap(const guint8 *pd, int len);
static int fix_pseudo_header(int encap, const guint8 *pd, int len, static int fix_pseudo_header(int encap, const guint8 *pd, int len,
union wtap_pseudo_header *pseudo_header); union wtap_pseudo_header *pseudo_header);
@ -519,11 +519,13 @@ static gboolean ngsniffer_dump_close(wtap_dumper *wdh, int *err);
static int SnifferDecompress( unsigned char * inbuf, size_t inlen, static int SnifferDecompress( unsigned char * inbuf, size_t inlen,
unsigned char * outbuf, size_t outlen, int *err ); unsigned char * outbuf, size_t outlen, int *err );
static gint64 ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, static gint64 ng_file_read(void *buffer, unsigned int nbytes, wtap *wth,
gboolean is_random, int *err); gboolean is_random, int *err, gchar **err_info);
static int read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, static int read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream,
int *err); int *err, gchar **err_info);
static gint64 ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err); static gint64 ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err,
static gint64 ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err); gchar **err_info);
static gint64 ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err,
gchar **err_info);
int int
ngsniffer_open(wtap *wth, int *err, gchar **err_info) ngsniffer_open(wtap *wth, int *err, gchar **err_info)
@ -559,7 +561,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, sizeof magic, wth->fh); bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) { if (bytes_read != sizeof magic) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -578,7 +580,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(record_type, 2, wth->fh); bytes_read = file_read(record_type, 2, wth->fh);
bytes_read += file_read(record_length, 4, wth->fh); bytes_read += file_read(record_length, 4, wth->fh);
if (bytes_read != 6) { if (bytes_read != 6) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -597,7 +599,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&version, sizeof version, wth->fh); bytes_read = file_read(&version, sizeof version, wth->fh);
if (bytes_read != sizeof version) { if (bytes_read != sizeof version) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -782,7 +784,7 @@ process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(record_type, 2, wth->fh); bytes_read = file_read(record_type, 2, wth->fh);
if (bytes_read != 2) { if (bytes_read != 2) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
if (bytes_read != 0) { if (bytes_read != 0) {
@ -813,7 +815,7 @@ process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(record_length, 4, wth->fh); bytes_read = file_read(record_length, 4, wth->fh);
if (bytes_read != 4) { if (bytes_read != 4) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -842,7 +844,7 @@ process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers,
bytes_read = file_read(buffer, bytes_to_read, bytes_read = file_read(buffer, bytes_to_read,
wth->fh); wth->fh);
if (bytes_read != bytes_to_read) { if (bytes_read != bytes_to_read) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -1048,7 +1050,7 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*/ */
*data_offset = wth->data_offset; *data_offset = wth->data_offset;
ret = ngsniffer_read_rec_header(wth, FALSE, &type, &length, ret = ngsniffer_read_rec_header(wth, FALSE, &type, &length,
err); err, err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
return FALSE; return FALSE;
@ -1069,7 +1071,8 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
} }
/* Read the f_frame2_struct */ /* Read the f_frame2_struct */
if (!ngsniffer_read_frame2(wth, FALSE, &frame2, err)) { if (!ngsniffer_read_frame2(wth, FALSE, &frame2, err,
err_info)) {
/* Read error */ /* Read error */
return FALSE; return FALSE;
} }
@ -1099,7 +1102,8 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
} }
/* Read the f_frame4_struct */ /* Read the f_frame4_struct */
if (!ngsniffer_read_frame4(wth, FALSE, &frame4, err)) { if (!ngsniffer_read_frame4(wth, FALSE, &frame4, err,
err_info)) {
/* Read error */ /* Read error */
return FALSE; return FALSE;
} }
@ -1130,7 +1134,8 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
case REC_FRAME6: case REC_FRAME6:
/* Read the f_frame6_struct */ /* Read the f_frame6_struct */
if (!ngsniffer_read_frame6(wth, FALSE, &frame6, err)) { if (!ngsniffer_read_frame6(wth, FALSE, &frame6, err,
err_info)) {
/* Read error */ /* Read error */
return FALSE; return FALSE;
} }
@ -1164,7 +1169,8 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
* it is but can't handle it. Skip past the data * it is but can't handle it. Skip past the data
* portion, and keep looping. * portion, and keep looping.
*/ */
if (ng_file_seek_seq(wth, length, SEEK_CUR, err) == -1) if (ng_file_seek_seq(wth, length, SEEK_CUR, err, err_info)
== -1)
return FALSE; return FALSE;
wth->data_offset += length; wth->data_offset += length;
} }
@ -1191,7 +1197,7 @@ found:
*/ */
buffer_assure_space(wth->frame_buffer, length); buffer_assure_space(wth->frame_buffer, length);
pd = buffer_start_ptr(wth->frame_buffer); pd = buffer_start_ptr(wth->frame_buffer);
if (!ngsniffer_read_rec_data(wth, FALSE, pd, length, err)) if (!ngsniffer_read_rec_data(wth, FALSE, pd, length, err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += length; wth->data_offset += length;
@ -1234,7 +1240,7 @@ found:
static gboolean static gboolean
ngsniffer_seek_read(wtap *wth, gint64 seek_off, ngsniffer_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
int ret; int ret;
guint16 type, length; guint16 type, length;
@ -1242,10 +1248,11 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
struct frame4_rec frame4; struct frame4_rec frame4;
struct frame6_rec frame6; struct frame6_rec frame6;
if (ng_file_seek_rand(wth, seek_off, SEEK_SET, err) == -1) if (ng_file_seek_rand(wth, seek_off, SEEK_SET, err, err_info) == -1)
return FALSE; return FALSE;
ret = ngsniffer_read_rec_header(wth, TRUE, &type, &length, err); ret = ngsniffer_read_rec_header(wth, TRUE, &type, &length, err,
err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
if (ret == 0) { if (ret == 0) {
@ -1259,7 +1266,7 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
case REC_FRAME2: case REC_FRAME2:
/* Read the f_frame2_struct */ /* Read the f_frame2_struct */
if (!ngsniffer_read_frame2(wth, TRUE, &frame2, err)) { if (!ngsniffer_read_frame2(wth, TRUE, &frame2, err, err_info)) {
/* Read error */ /* Read error */
return FALSE; return FALSE;
} }
@ -1271,7 +1278,7 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
case REC_FRAME4: case REC_FRAME4:
/* Read the f_frame4_struct */ /* Read the f_frame4_struct */
if (!ngsniffer_read_frame4(wth, TRUE, &frame4, err)) { if (!ngsniffer_read_frame4(wth, TRUE, &frame4, err, err_info)) {
/* Read error */ /* Read error */
return FALSE; return FALSE;
} }
@ -1283,7 +1290,7 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
case REC_FRAME6: case REC_FRAME6:
/* Read the f_frame6_struct */ /* Read the f_frame6_struct */
if (!ngsniffer_read_frame6(wth, TRUE, &frame6, err)) { if (!ngsniffer_read_frame6(wth, TRUE, &frame6, err, err_info)) {
/* Read error */ /* Read error */
return FALSE; return FALSE;
} }
@ -1304,7 +1311,7 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
/* /*
* Got the pseudo-header (if any), now get the data. * Got the pseudo-header (if any), now get the data.
*/ */
if (!ngsniffer_read_rec_data(wth, TRUE, pd, packet_size, err)) if (!ngsniffer_read_rec_data(wth, TRUE, pd, packet_size, err, err_info))
return FALSE; return FALSE;
fix_pseudo_header(wth->file_encap, pd, packet_size, pseudo_header); fix_pseudo_header(wth->file_encap, pd, packet_size, pseudo_header);
@ -1314,7 +1321,7 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
static int static int
ngsniffer_read_rec_header(wtap *wth, gboolean is_random, guint16 *typep, ngsniffer_read_rec_header(wtap *wth, gboolean is_random, guint16 *typep,
guint16 *lengthp, int *err) guint16 *lengthp, int *err, gchar **err_info)
{ {
gint64 bytes_read; gint64 bytes_read;
char record_type[2]; char record_type[2];
@ -1323,7 +1330,8 @@ ngsniffer_read_rec_header(wtap *wth, gboolean is_random, guint16 *typep,
/* /*
* Read the record header. * Read the record header.
*/ */
bytes_read = ng_file_read(record_type, 2, wth, is_random, err); bytes_read = ng_file_read(record_type, 2, wth, is_random, err,
err_info);
if (bytes_read != 2) { if (bytes_read != 2) {
if (*err != 0) if (*err != 0)
return -1; return -1;
@ -1333,7 +1341,8 @@ ngsniffer_read_rec_header(wtap *wth, gboolean is_random, guint16 *typep,
} }
return 0; return 0;
} }
bytes_read = ng_file_read(record_length, 4, wth, is_random, err); bytes_read = ng_file_read(record_length, 4, wth, is_random, err,
err_info);
if (bytes_read != 4) { if (bytes_read != 4) {
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -1347,13 +1356,13 @@ ngsniffer_read_rec_header(wtap *wth, gboolean is_random, guint16 *typep,
static gboolean static gboolean
ngsniffer_read_frame2(wtap *wth, gboolean is_random, struct frame2_rec *frame2, ngsniffer_read_frame2(wtap *wth, gboolean is_random, struct frame2_rec *frame2,
int *err) int *err, gchar **err_info)
{ {
gint64 bytes_read; gint64 bytes_read;
/* Read the f_frame2_struct */ /* Read the f_frame2_struct */
bytes_read = ng_file_read(frame2, (unsigned int)sizeof *frame2, wth, bytes_read = ng_file_read(frame2, (unsigned int)sizeof *frame2, wth,
is_random, err); is_random, err, err_info);
if (bytes_read != sizeof *frame2) { if (bytes_read != sizeof *frame2) {
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -1457,13 +1466,13 @@ set_pseudo_header_frame2(wtap *wth, union wtap_pseudo_header *pseudo_header,
static gboolean static gboolean
ngsniffer_read_frame4(wtap *wth, gboolean is_random, struct frame4_rec *frame4, ngsniffer_read_frame4(wtap *wth, gboolean is_random, struct frame4_rec *frame4,
int *err) int *err, gchar **err_info)
{ {
gint64 bytes_read; gint64 bytes_read;
/* Read the f_frame4_struct */ /* Read the f_frame4_struct */
bytes_read = ng_file_read(frame4, (unsigned int)sizeof *frame4, wth, bytes_read = ng_file_read(frame4, (unsigned int)sizeof *frame4, wth,
is_random, err); is_random, err, err_info);
if (bytes_read != sizeof *frame4) { if (bytes_read != sizeof *frame4) {
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -1728,13 +1737,13 @@ set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header,
static gboolean static gboolean
ngsniffer_read_frame6(wtap *wth, gboolean is_random, struct frame6_rec *frame6, ngsniffer_read_frame6(wtap *wth, gboolean is_random, struct frame6_rec *frame6,
int *err) int *err, gchar **err_info)
{ {
gint64 bytes_read; gint64 bytes_read;
/* Read the f_frame6_struct */ /* Read the f_frame6_struct */
bytes_read = ng_file_read(frame6, (unsigned int)sizeof *frame6, wth, bytes_read = ng_file_read(frame6, (unsigned int)sizeof *frame6, wth,
is_random, err); is_random, err, err_info);
if (bytes_read != sizeof *frame6) { if (bytes_read != sizeof *frame6) {
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -1760,11 +1769,11 @@ set_pseudo_header_frame6(wtap *wth, union wtap_pseudo_header *pseudo_header,
static gboolean static gboolean
ngsniffer_read_rec_data(wtap *wth, gboolean is_random, guchar *pd, ngsniffer_read_rec_data(wtap *wth, gboolean is_random, guchar *pd,
unsigned int length, int *err) unsigned int length, int *err, gchar **err_info)
{ {
gint64 bytes_read; gint64 bytes_read;
bytes_read = ng_file_read(pd, length, wth, is_random, err); bytes_read = ng_file_read(pd, length, wth, is_random, err, err_info);
if (bytes_read != (gint64) length) { if (bytes_read != (gint64) length) {
if (*err == 0) if (*err == 0)
@ -2414,7 +2423,7 @@ typedef struct {
static gint64 static gint64
ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, gboolean is_random, ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, gboolean is_random,
int *err) int *err, gchar **err_info)
{ {
ngsniffer_t *ngsniffer; ngsniffer_t *ngsniffer;
FILE_T infile; FILE_T infile;
@ -2439,7 +2448,7 @@ ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, gboolean is_random,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
copied_bytes = file_read(buffer, copybytes, infile); copied_bytes = file_read(buffer, copybytes, infile);
if ((unsigned int) copied_bytes != copybytes) if ((unsigned int) copied_bytes != copybytes)
*err = file_error(infile); *err = file_error(infile, err_info);
return copied_bytes; return copied_bytes;
} }
@ -2470,7 +2479,7 @@ ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, gboolean is_random,
} }
/* Now read the first blob into the buffer. */ /* Now read the first blob into the buffer. */
if (read_blob(infile, comp_stream, err) < 0) if (read_blob(infile, comp_stream, err, err_info) < 0)
return -1; return -1;
} }
while (copybytes > 0) { while (copybytes > 0) {
@ -2506,7 +2515,7 @@ ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, gboolean is_random,
} }
} }
if (read_blob(infile, comp_stream, err) < 0) if (read_blob(infile, comp_stream, err, err_info) < 0)
return -1; return -1;
bytes_left = comp_stream->nbytes - comp_stream->nextout; bytes_left = comp_stream->nbytes - comp_stream->nextout;
} }
@ -2526,9 +2535,10 @@ ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, gboolean is_random,
} }
/* Read a blob from a compressed stream. /* Read a blob from a compressed stream.
Return -1 and set "*err" on error, otherwise return 0. */ Return -1 and set "*err" and "*err_info" on error, otherwise return 0. */
static int static int
read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err) read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err,
gchar **err_info)
{ {
int in_len; int in_len;
size_t read_len; size_t read_len;
@ -2542,7 +2552,7 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
read_len = file_read(&blob_len, 2, infile); read_len = file_read(&blob_len, 2, infile);
if (2 != read_len) { if (2 != read_len) {
*err = file_error(infile); *err = file_error(infile, err_info);
return -1; return -1;
} }
comp_stream->comp_offset += 2; comp_stream->comp_offset += 2;
@ -2564,7 +2574,7 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
read_len = file_read(file_inbuf, in_len, infile); read_len = file_read(file_inbuf, in_len, infile);
if ((size_t) in_len != read_len) { if ((size_t) in_len != read_len) {
*err = file_error(infile); *err = file_error(infile, err_info);
g_free(file_inbuf); g_free(file_inbuf);
return -1; return -1;
} }
@ -2592,7 +2602,8 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err)
/* Seek in the sequential data stream; we can only seek forward, and we /* Seek in the sequential data stream; we can only seek forward, and we
do it on compressed files by skipping forward. */ do it on compressed files by skipping forward. */
static gint64 static gint64
ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err) ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err,
gchar **err_info)
{ {
gint64 delta; gint64 delta;
char *buf; char *buf;
@ -2628,7 +2639,7 @@ ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err)
else else
amount_to_read = (unsigned int) delta; amount_to_read = (unsigned int) delta;
if (ng_file_read(buf, amount_to_read, wth, FALSE, err) < 0) { if (ng_file_read(buf, amount_to_read, wth, FALSE, err, err_info) < 0) {
g_free(buf); g_free(buf);
return -1; /* error */ return -1; /* error */
} }
@ -2649,7 +2660,8 @@ ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err)
position within the blob we have in memory (whether it's the blob we position within the blob we have in memory (whether it's the blob we
already had in memory or, if necessary, the one we read in). */ already had in memory or, if necessary, the one we read in). */
static gint64 static gint64
ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err) ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err,
gchar **err_info)
{ {
ngsniffer_t *ngsniffer; ngsniffer_t *ngsniffer;
gint64 delta; gint64 delta;
@ -2744,7 +2756,7 @@ ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err)
ngsniffer->rand.comp_offset = new_blob->blob_comp_offset; ngsniffer->rand.comp_offset = new_blob->blob_comp_offset;
/* Now fill the buffer. */ /* Now fill the buffer. */
if (read_blob(wth->random_fh, &ngsniffer->rand, err) < 0) if (read_blob(wth->random_fh, &ngsniffer->rand, err, err_info) < 0)
return -1; return -1;
/* Set "delta" to the amount to move within this blob; it had /* Set "delta" to the amount to move within this blob; it had

View File

@ -50,22 +50,22 @@ typedef struct packetlogger_header {
#define PACKETLOGGER_HEADER_SIZE 12 #define PACKETLOGGER_HEADER_SIZE 12
static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info _U_, static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset); gint64 *data_offset);
static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off, static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header _U_, union wtap_pseudo_header *pseudo_header _U_,
guchar *pd, int length, int *err, guchar *pd, int length, int *err,
gchar **err_info _U_); gchar **err_info);
static gboolean packetlogger_read_header(packetlogger_header_t *pl_hdr, static gboolean packetlogger_read_header(packetlogger_header_t *pl_hdr,
FILE_T fh, int *err); FILE_T fh, int *err, gchar **err_info);
int packetlogger_open(wtap *wth, int *err, gchar **err_info _U_) int packetlogger_open(wtap *wth, int *err, gchar **err_info)
{ {
packetlogger_header_t pl_hdr; packetlogger_header_t pl_hdr;
guint8 type; guint8 type;
if(!packetlogger_read_header(&pl_hdr, wth->fh, err)) if(!packetlogger_read_header(&pl_hdr, wth->fh, err, err_info))
return -1; return -1;
if (file_read(&type, 1, wth->fh) <= 0) if (file_read(&type, 1, wth->fh) <= 0)
@ -100,7 +100,7 @@ packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*data_offset = wth->data_offset; *data_offset = wth->data_offset;
if(!packetlogger_read_header(&pl_hdr, wth->fh, err)) if(!packetlogger_read_header(&pl_hdr, wth->fh, err, err_info))
return FALSE; return FALSE;
if (pl_hdr.len < 8) { if (pl_hdr.len < 8) {
@ -114,7 +114,7 @@ packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
pl_hdr.len - 8, pl_hdr.len - 8,
wth->fh); wth->fh);
if(bytes_read != pl_hdr.len - 8) { if(bytes_read != pl_hdr.len - 8) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if(*err == 0) if(*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -135,7 +135,7 @@ packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
static gboolean static gboolean
packetlogger_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header packetlogger_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
*pseudo_header _U_, guchar *pd, int length, int *err, *pseudo_header _U_, guchar *pd, int length, int *err,
gchar **err_info _U_) gchar **err_info)
{ {
packetlogger_header_t pl_hdr; packetlogger_header_t pl_hdr;
guint bytes_read; guint bytes_read;
@ -143,7 +143,7 @@ packetlogger_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE; return FALSE;
if(!packetlogger_read_header(&pl_hdr, wth->random_fh, err)) { if(!packetlogger_read_header(&pl_hdr, wth->random_fh, err, err_info)) {
if(*err == 0) if(*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -158,7 +158,7 @@ packetlogger_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
bytes_read = file_read(pd, pl_hdr.len - 8, wth->random_fh); bytes_read = file_read(pd, pl_hdr.len - 8, wth->random_fh);
if(bytes_read != (pl_hdr.len - 8)) { if(bytes_read != (pl_hdr.len - 8)) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
if(*err == 0) if(*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -169,7 +169,8 @@ packetlogger_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
} }
static gboolean static gboolean
packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, int *err) packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, int *err,
gchar **err_info)
{ {
guint bytes_read = 0; guint bytes_read = 0;
@ -181,7 +182,7 @@ packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, int *err)
pl_hdr->ts = GUINT64_FROM_BE(pl_hdr->ts); pl_hdr->ts = GUINT64_FROM_BE(pl_hdr->ts);
if(bytes_read < PACKETLOGGER_HEADER_SIZE) { if(bytes_read < PACKETLOGGER_HEADER_SIZE) {
*err = file_error(fh); *err = file_error(fh, err_info);
if(*err == 0 && bytes_read > 0) if(*err == 0 && bytes_read > 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;

View File

@ -710,7 +710,7 @@ struct i2c_file_hdr {
static gboolean static gboolean
pcap_read_sunatm_pseudoheader(FILE_T fh, pcap_read_sunatm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err) union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{ {
guint8 atm_phdr[SUNATM_LEN]; guint8 atm_phdr[SUNATM_LEN];
int bytes_read; int bytes_read;
@ -720,7 +720,7 @@ pcap_read_sunatm_pseudoheader(FILE_T fh,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(atm_phdr, SUNATM_LEN, fh); bytes_read = file_read(atm_phdr, SUNATM_LEN, fh);
if (bytes_read != SUNATM_LEN) { if (bytes_read != SUNATM_LEN) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -798,7 +798,7 @@ pcap_read_sunatm_pseudoheader(FILE_T fh,
static gboolean static gboolean
pcap_read_nokiaatm_pseudoheader(FILE_T fh, pcap_read_nokiaatm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err) union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{ {
guint8 atm_phdr[NOKIAATM_LEN]; guint8 atm_phdr[NOKIAATM_LEN];
int bytes_read; int bytes_read;
@ -808,7 +808,7 @@ pcap_read_nokiaatm_pseudoheader(FILE_T fh,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(atm_phdr, NOKIAATM_LEN, fh); bytes_read = file_read(atm_phdr, NOKIAATM_LEN, fh);
if (bytes_read != NOKIAATM_LEN) { if (bytes_read != NOKIAATM_LEN) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -841,7 +841,7 @@ pcap_read_irda_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(irda_phdr, IRDA_SLL_LEN, fh); bytes_read = file_read(irda_phdr, IRDA_SLL_LEN, fh);
if (bytes_read != IRDA_SLL_LEN) { if (bytes_read != IRDA_SLL_LEN) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -860,7 +860,7 @@ pcap_read_irda_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
} }
static gboolean static gboolean
pcap_read_mtp2_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info _U_) pcap_read_mtp2_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{ {
guint8 mtp2_hdr[MTP2_HDR_LEN]; guint8 mtp2_hdr[MTP2_HDR_LEN];
int bytes_read; int bytes_read;
@ -868,7 +868,7 @@ pcap_read_mtp2_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(mtp2_hdr, MTP2_HDR_LEN, fh); bytes_read = file_read(mtp2_hdr, MTP2_HDR_LEN, fh);
if (bytes_read != MTP2_HDR_LEN) { if (bytes_read != MTP2_HDR_LEN) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -891,7 +891,7 @@ pcap_read_lapd_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(lapd_phdr, LAPD_SLL_LEN, fh); bytes_read = file_read(lapd_phdr, LAPD_SLL_LEN, fh);
if (bytes_read != LAPD_SLL_LEN) { if (bytes_read != LAPD_SLL_LEN) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -911,7 +911,7 @@ pcap_read_lapd_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
} }
static gboolean static gboolean
pcap_read_sita_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info _U_) pcap_read_sita_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{ {
guint8 sita_phdr[SITA_HDR_LEN]; guint8 sita_phdr[SITA_HDR_LEN];
int bytes_read; int bytes_read;
@ -919,7 +919,7 @@ pcap_read_sita_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(sita_phdr, SITA_HDR_LEN, fh); bytes_read = file_read(sita_phdr, SITA_HDR_LEN, fh);
if (bytes_read != SITA_HDR_LEN) { if (bytes_read != SITA_HDR_LEN) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -1174,7 +1174,7 @@ pcap_process_linux_usb_pseudoheader(guint packet_size, gboolean byte_swapped,
static gboolean static gboolean
pcap_read_bt_pseudoheader(FILE_T fh, pcap_read_bt_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err) union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
struct libpcap_bt_phdr phdr; struct libpcap_bt_phdr phdr;
@ -1183,7 +1183,7 @@ pcap_read_bt_pseudoheader(FILE_T fh,
bytes_read = file_read(&phdr, bytes_read = file_read(&phdr,
sizeof (struct libpcap_bt_phdr), fh); sizeof (struct libpcap_bt_phdr), fh);
if (bytes_read != sizeof (struct libpcap_bt_phdr)) { if (bytes_read != sizeof (struct libpcap_bt_phdr)) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -1194,7 +1194,7 @@ pcap_read_bt_pseudoheader(FILE_T fh,
static gboolean static gboolean
pcap_read_ppp_pseudoheader(FILE_T fh, pcap_read_ppp_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err) union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
struct libpcap_ppp_phdr phdr; struct libpcap_ppp_phdr phdr;
@ -1203,7 +1203,7 @@ pcap_read_ppp_pseudoheader(FILE_T fh,
bytes_read = file_read(&phdr, bytes_read = file_read(&phdr,
sizeof (struct libpcap_ppp_phdr), fh); sizeof (struct libpcap_ppp_phdr), fh);
if (bytes_read != sizeof (struct libpcap_ppp_phdr)) { if (bytes_read != sizeof (struct libpcap_ppp_phdr)) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -1214,7 +1214,7 @@ pcap_read_ppp_pseudoheader(FILE_T fh,
static gboolean static gboolean
pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr, pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr,
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info _U_) union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{ {
guint8 erf_hdr[sizeof(struct erf_phdr)]; guint8 erf_hdr[sizeof(struct erf_phdr)];
int bytes_read; int bytes_read;
@ -1222,7 +1222,7 @@ pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_hdr, sizeof(struct erf_phdr), fh); bytes_read = file_read(erf_hdr, sizeof(struct erf_phdr), fh);
if (bytes_read != sizeof(struct erf_phdr)) { if (bytes_read != sizeof(struct erf_phdr)) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -1257,7 +1257,7 @@ pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr,
*/ */
static gboolean static gboolean
pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
int *err, gchar **err_info _U_, guint * psize) int *err, gchar **err_info, guint * psize)
{ {
int bytes_read = 0; int bytes_read = 0;
guint8 erf_exhdr[8]; guint8 erf_exhdr[8];
@ -1270,7 +1270,7 @@ pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_exhdr, 8, fh); bytes_read = file_read(erf_exhdr, 8, fh);
if (bytes_read != 8 ) { if (bytes_read != 8 ) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -1292,7 +1292,7 @@ pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
*/ */
static gboolean static gboolean
pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
int *err, gchar **err_info _U_, guint * psize) int *err, gchar **err_info, guint * psize)
{ {
guint8 erf_subhdr[sizeof(union erf_subhdr)]; guint8 erf_subhdr[sizeof(union erf_subhdr)];
int bytes_read; int bytes_read;
@ -1310,7 +1310,7 @@ pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_subhdr, sizeof(erf_mc_header_t), fh); bytes_read = file_read(erf_subhdr, sizeof(erf_mc_header_t), fh);
if (bytes_read != sizeof(erf_mc_header_t) ) { if (bytes_read != sizeof(erf_mc_header_t) ) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -1325,7 +1325,7 @@ pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_subhdr, sizeof(erf_eth_header_t), fh); bytes_read = file_read(erf_subhdr, sizeof(erf_eth_header_t), fh);
if (bytes_read != sizeof(erf_eth_header_t) ) { if (bytes_read != sizeof(erf_eth_header_t) ) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -1341,7 +1341,7 @@ pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
} }
static gboolean static gboolean
pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info _U_) pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{ {
struct i2c_file_hdr i2c_hdr; struct i2c_file_hdr i2c_hdr;
int bytes_read; int bytes_read;
@ -1349,7 +1349,7 @@ pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, i
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&i2c_hdr, sizeof (i2c_hdr), fh); bytes_read = file_read(&i2c_hdr, sizeof (i2c_hdr), fh);
if (bytes_read != sizeof (i2c_hdr)) { if (bytes_read != sizeof (i2c_hdr)) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -1388,7 +1388,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap,
return -1; return -1;
} }
if (!pcap_read_nokiaatm_pseudoheader(fh, if (!pcap_read_nokiaatm_pseudoheader(fh,
pseudo_header, err)) pseudo_header, err, err_info))
return -1; /* Read error */ return -1; /* Read error */
phdr_len = NOKIAATM_LEN; phdr_len = NOKIAATM_LEN;
@ -1407,7 +1407,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap,
return -1; return -1;
} }
if (!pcap_read_sunatm_pseudoheader(fh, if (!pcap_read_sunatm_pseudoheader(fh,
pseudo_header, err)) pseudo_header, err, err_info))
return -1; /* Read error */ return -1; /* Read error */
phdr_len = SUNATM_LEN; phdr_len = SUNATM_LEN;
@ -1526,7 +1526,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap,
return -1; return -1;
} }
if (!pcap_read_bt_pseudoheader(fh, if (!pcap_read_bt_pseudoheader(fh,
pseudo_header, err)) pseudo_header, err, err_info))
return -1; /* Read error */ return -1; /* Read error */
phdr_len = (int)sizeof (struct libpcap_bt_phdr); phdr_len = (int)sizeof (struct libpcap_bt_phdr);
@ -1545,7 +1545,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap,
return -1; return -1;
} }
if (!pcap_read_ppp_pseudoheader(fh, if (!pcap_read_ppp_pseudoheader(fh,
pseudo_header, err)) pseudo_header, err, err_info))
return -1; /* Read error */ return -1; /* Read error */
phdr_len = (int)sizeof (struct libpcap_ppp_phdr); phdr_len = (int)sizeof (struct libpcap_ppp_phdr);

View File

@ -334,7 +334,7 @@ pcapng_get_encap(gint id, pcapng_t *pn)
static int static int
pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh, pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh,
char *content, int len, int *err, gchar **err_info _U_) char *content, int len, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
int block_read; int block_read;
@ -346,7 +346,7 @@ pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh,
bytes_read = file_read(oh, sizeof (*oh), fh); bytes_read = file_read(oh, sizeof (*oh), fh);
if (bytes_read != sizeof (*oh)) { if (bytes_read != sizeof (*oh)) {
pcapng_debug0("pcapng_read_option: failed to read option"); pcapng_debug0("pcapng_read_option: failed to read option");
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -369,7 +369,7 @@ pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh,
bytes_read = file_read(content, oh->option_length, fh); bytes_read = file_read(content, oh->option_length, fh);
if (bytes_read != oh->option_length) { if (bytes_read != oh->option_length) {
pcapng_debug1("pcapng_read_if_descr_block: failed to read content of option %u", oh->option_code); pcapng_debug1("pcapng_read_if_descr_block: failed to read content of option %u", oh->option_code);
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -409,7 +409,7 @@ pcapng_read_section_header_block(FILE_T fh, gboolean first_block,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&shb, sizeof shb, fh); bytes_read = file_read(&shb, sizeof shb, fh);
if (bytes_read != sizeof shb) { if (bytes_read != sizeof shb) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
if (first_block) { if (first_block) {
/* /*
@ -569,7 +569,7 @@ pcapng_read_section_header_block(FILE_T fh, gboolean first_block,
/* "Interface Description Block" */ /* "Interface Description Block" */
static int static int
pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
wtapng_block_t *wblock, int *err, gchar **err_info _U_) wtapng_block_t *wblock, int *err, gchar **err_info)
{ {
guint64 time_units_per_second; guint64 time_units_per_second;
int bytes_read; int bytes_read;
@ -588,7 +588,7 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
bytes_read = file_read(&idb, sizeof idb, fh); bytes_read = file_read(&idb, sizeof idb, fh);
if (bytes_read != sizeof idb) { if (bytes_read != sizeof idb) {
pcapng_debug0("pcapng_read_if_descr_block: failed to read IDB"); pcapng_debug0("pcapng_read_if_descr_block: failed to read IDB");
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -769,7 +769,7 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
static int static int
pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info _U_, gboolean enhanced) pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info, gboolean enhanced)
{ {
int bytes_read; int bytes_read;
int block_read; int block_read;
@ -790,7 +790,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
bytes_read = file_read(&epb, sizeof epb, fh); bytes_read = file_read(&epb, sizeof epb, fh);
if (bytes_read != sizeof epb) { if (bytes_read != sizeof epb) {
pcapng_debug0("pcapng_read_packet_block: failed to read packet data"); pcapng_debug0("pcapng_read_packet_block: failed to read packet data");
*err = file_error(fh); *err = file_error(fh, err_info);
return 0; return 0;
} }
block_read = bytes_read; block_read = bytes_read;
@ -814,7 +814,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
bytes_read = file_read(&pb, sizeof pb, fh); bytes_read = file_read(&pb, sizeof pb, fh);
if (bytes_read != sizeof pb) { if (bytes_read != sizeof pb) {
pcapng_debug0("pcapng_read_packet_block: failed to read packet data"); pcapng_debug0("pcapng_read_packet_block: failed to read packet data");
*err = file_error(fh); *err = file_error(fh, err_info);
return 0; return 0;
} }
block_read = bytes_read; block_read = bytes_read;
@ -889,7 +889,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read((guchar *) (wblock->frame_buffer), wblock->data.packet.cap_len - pseudo_header_len, fh); bytes_read = file_read((guchar *) (wblock->frame_buffer), wblock->data.packet.cap_len - pseudo_header_len, fh);
if (bytes_read != (int) (wblock->data.packet.cap_len - pseudo_header_len)) { if (bytes_read != (int) (wblock->data.packet.cap_len - pseudo_header_len)) {
*err = file_error(fh); *err = file_error(fh, err_info);
pcapng_debug1("pcapng_read_packet_block: couldn't read %u bytes of captured data", pcapng_debug1("pcapng_read_packet_block: couldn't read %u bytes of captured data",
wblock->data.packet.cap_len - pseudo_header_len); wblock->data.packet.cap_len - pseudo_header_len);
if (*err == 0) if (*err == 0)
@ -982,7 +982,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
static int static int
pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info _U_) pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
int block_read; int block_read;
@ -997,7 +997,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
bytes_read = file_read(&spb, sizeof spb, fh); bytes_read = file_read(&spb, sizeof spb, fh);
if (bytes_read != sizeof spb) { if (bytes_read != sizeof spb) {
pcapng_debug0("pcapng_read_simple_packet_block: failed to read packet data"); pcapng_debug0("pcapng_read_simple_packet_block: failed to read packet data");
*err = file_error(fh); *err = file_error(fh, err_info);
return 0; return 0;
} }
block_read = bytes_read; block_read = bytes_read;
@ -1062,7 +1062,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read((guchar *) (wblock->frame_buffer), wblock->data.simple_packet.cap_len, fh); bytes_read = file_read((guchar *) (wblock->frame_buffer), wblock->data.simple_packet.cap_len, fh);
if (bytes_read != (int) wblock->data.simple_packet.cap_len) { if (bytes_read != (int) wblock->data.simple_packet.cap_len) {
*err = file_error(fh); *err = file_error(fh, err_info);
pcapng_debug1("pcapng_read_simple_packet_block: couldn't read %u bytes of captured data", pcapng_debug1("pcapng_read_simple_packet_block: couldn't read %u bytes of captured data",
wblock->data.simple_packet.cap_len); wblock->data.simple_packet.cap_len);
if (*err == 0) if (*err == 0)
@ -1094,7 +1094,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
/* IPv6 + MAXNAMELEN */ /* IPv6 + MAXNAMELEN */
#define MAX_NRB_REC_SIZE (16 + 64) #define MAX_NRB_REC_SIZE (16 + 64)
static int static int
pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock _U_,int *err, gchar **err_info _U_) pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock _U_,int *err, gchar **err_info)
{ {
int bytes_read = 0; int bytes_read = 0;
int block_read = 0; int block_read = 0;
@ -1113,7 +1113,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
bytes_read = file_read(&nrb, sizeof nrb, fh); bytes_read = file_read(&nrb, sizeof nrb, fh);
if (bytes_read != sizeof nrb) { if (bytes_read != sizeof nrb) {
pcapng_debug0("pcapng_read_name_resolution_block: failed to read record header"); pcapng_debug0("pcapng_read_name_resolution_block: failed to read record header");
*err = file_error(fh); *err = file_error(fh, err_info);
return 0; return 0;
} }
block_read += bytes_read; block_read += bytes_read;
@ -1136,7 +1136,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
bytes_read = file_read(nrb_rec, nrb.record_len, fh); bytes_read = file_read(nrb_rec, nrb.record_len, fh);
if (bytes_read != nrb.record_len) { if (bytes_read != nrb.record_len) {
pcapng_debug0("pcapng_read_name_resolution_block: failed to read IPv4 record data"); pcapng_debug0("pcapng_read_name_resolution_block: failed to read IPv4 record data");
*err = file_error(fh); *err = file_error(fh, err_info);
return 0; return 0;
} }
block_read += bytes_read; block_read += bytes_read;
@ -1164,7 +1164,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
bytes_read = file_read(nrb_rec, nrb.record_len, fh); bytes_read = file_read(nrb_rec, nrb.record_len, fh);
if (bytes_read != nrb.record_len) { if (bytes_read != nrb.record_len) {
pcapng_debug0("pcapng_read_name_resolution_block: failed to read IPv6 record data"); pcapng_debug0("pcapng_read_name_resolution_block: failed to read IPv6 record data");
*err = file_error(fh); *err = file_error(fh, err_info);
return 0; return 0;
} }
block_read += bytes_read; block_read += bytes_read;
@ -1198,7 +1198,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
} }
static int static int
pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock,int *err, gchar **err_info _U_) pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock,int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
int block_read; int block_read;
@ -1213,7 +1213,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
bytes_read = file_read(&isb, sizeof isb, fh); bytes_read = file_read(&isb, sizeof isb, fh);
if (bytes_read != sizeof isb) { if (bytes_read != sizeof isb) {
pcapng_debug0("pcapng_read_interface_statistics_block: failed to read packet data"); pcapng_debug0("pcapng_read_interface_statistics_block: failed to read packet data");
*err = file_error(fh); *err = file_error(fh, err_info);
return 0; return 0;
} }
block_read = bytes_read; block_read = bytes_read;
@ -1346,7 +1346,7 @@ pcapng_read_block(FILE_T fh, gboolean first_block, pcapng_t *pn, wtapng_block_t
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&bh, sizeof bh, fh); bytes_read = file_read(&bh, sizeof bh, fh);
if (bytes_read != sizeof bh) { if (bytes_read != sizeof bh) {
*err = file_error(fh); *err = file_error(fh, err_info);
pcapng_debug3("pcapng_read_block: file_read() returned %d instead of %u, err = %d.", bytes_read, (unsigned int)sizeof bh, *err); pcapng_debug3("pcapng_read_block: file_read() returned %d instead of %u, err = %d.", bytes_read, (unsigned int)sizeof bh, *err);
if (*err != 0) if (*err != 0)
return -1; return -1;
@ -1414,7 +1414,7 @@ pcapng_read_block(FILE_T fh, gboolean first_block, pcapng_t *pn, wtapng_block_t
bytes_read = file_read(&block_total_length, sizeof block_total_length, fh); bytes_read = file_read(&block_total_length, sizeof block_total_length, fh);
if (bytes_read != sizeof block_total_length) { if (bytes_read != sizeof block_total_length) {
pcapng_debug0("pcapng_read_block: couldn't read second block length"); pcapng_debug0("pcapng_read_block: couldn't read second block length");
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return -1; return -1;
@ -1463,7 +1463,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
bytes_read = pcapng_read_block(wth->fh, TRUE, &pn, &wblock, err, err_info); bytes_read = pcapng_read_block(wth->fh, TRUE, &pn, &wblock, err, err_info);
if (bytes_read <= 0) { if (bytes_read <= 0) {
pcapng_debug0("pcapng_open: couldn't read first SHB"); pcapng_debug0("pcapng_open: couldn't read first SHB");
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -1608,7 +1608,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
/* read the block */ /* read the block */
bytes_read = pcapng_read_block(wth->random_fh, FALSE, pcapng, &wblock, err, err_info); bytes_read = pcapng_read_block(wth->random_fh, FALSE, pcapng, &wblock, err, err_info);
if (bytes_read <= 0) { if (bytes_read <= 0) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
pcapng_debug3("pcapng_seek_read: couldn't read packet block (err=%d, errno=%d, bytes_read=%d).", pcapng_debug3("pcapng_seek_read: couldn't read packet block (err=%d, errno=%d, bytes_read=%d).",
*err, errno, bytes_read); *err, errno, bytes_read);
return FALSE; return FALSE;

View File

@ -211,7 +211,7 @@ typedef struct _pppdump_t {
static int static int
process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd, process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd,
int *err, pkt_id *pid); int *err, gchar **err_info, pkt_id *pid);
static gboolean static gboolean
collate(pppdump_t*, FILE_T fh, int *err, gchar **err_info, guint8 *pd, collate(pppdump_t*, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
@ -248,7 +248,7 @@ init_state(pppdump_t *state)
int int
pppdump_open(wtap *wth, int *err, gchar **err_info _U_) pppdump_open(wtap *wth, int *err, gchar **err_info)
{ {
guint8 buffer[6]; /* Looking for: 0x07 t3 t2 t1 t0 ID */ guint8 buffer[6]; /* Looking for: 0x07 t3 t2 t1 t0 ID */
pppdump_t *state; pppdump_t *state;
@ -261,7 +261,8 @@ pppdump_open(wtap *wth, int *err, gchar **err_info _U_)
* representing the timestamp. * representing the timestamp.
*/ */
wtap_file_read_unknown_bytes(buffer, sizeof(buffer), wth->fh, err); wtap_file_read_unknown_bytes(buffer, sizeof(buffer), wth->fh, err,
err_info);
if (buffer[0] == PPPD_RESET_TIME && if (buffer[0] == PPPD_RESET_TIME &&
(buffer[5] == PPPD_SENT_DATA || (buffer[5] == PPPD_SENT_DATA ||
@ -373,7 +374,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*/ */
static int static int
process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd, process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd,
int *err, pkt_id *pid) int *err, gchar **err_info, pkt_id *pid)
{ {
int c; int c;
int num_bytes = n; int num_bytes = n;
@ -382,7 +383,7 @@ process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd,
for (; num_bytes > 0; --num_bytes) { for (; num_bytes > 0; --num_bytes) {
c = file_getc(fh); c = file_getc(fh);
if (c == EOF) { if (c == EOF) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -548,7 +549,7 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
g_assert(num_bytes_to_skip == 0); g_assert(num_bytes_to_skip == 0);
pkt = state->pkt; pkt = state->pkt;
num_written = process_data(state, fh, pkt, state->num_bytes, num_written = process_data(state, fh, pkt, state->num_bytes,
pd, err, pid); pd, err, err_info, pid);
if (num_written < 0) { if (num_written < 0) {
return FALSE; return FALSE;
@ -628,7 +629,7 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
n--; n--;
} }
num_written = process_data(state, fh, pkt, n, num_written = process_data(state, fh, pkt, n,
pd, err, pid); pd, err, err_info, pid);
if (num_written < 0) { if (num_written < 0) {
return FALSE; return FALSE;
@ -647,14 +648,14 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
break; break;
case PPPD_RESET_TIME: case PPPD_RESET_TIME:
wtap_file_read_unknown_bytes(&time_long, sizeof(guint32), fh, err); wtap_file_read_unknown_bytes(&time_long, sizeof(guint32), fh, err, err_info);
state->offset += sizeof(guint32); state->offset += sizeof(guint32);
state->timestamp = pntohl(&time_long); state->timestamp = pntohl(&time_long);
state->tenths = 0; state->tenths = 0;
break; break;
case PPPD_TIME_STEP_LONG: case PPPD_TIME_STEP_LONG:
wtap_file_read_unknown_bytes(&time_long, sizeof(guint32), fh, err); wtap_file_read_unknown_bytes(&time_long, sizeof(guint32), fh, err, err_info);
state->offset += sizeof(guint32); state->offset += sizeof(guint32);
state->tenths += pntohl(&time_long); state->tenths += pntohl(&time_long);
@ -666,7 +667,7 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
break; break;
case PPPD_TIME_STEP_SHORT: case PPPD_TIME_STEP_SHORT:
wtap_file_read_unknown_bytes(&time_short, sizeof(guint8), fh, err); wtap_file_read_unknown_bytes(&time_short, sizeof(guint8), fh, err, err_info);
state->offset += sizeof(guint8); state->offset += sizeof(guint8);
state->tenths += time_short; state->tenths += time_short;
@ -687,7 +688,7 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
} }
done: done:
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
if (state->offset != start_offset) { if (state->offset != start_offset) {
/* /*

View File

@ -95,9 +95,9 @@ static gboolean radcom_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info); int *err, gchar **err_info);
static int radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, static int radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr,
int *err); int *err, gchar **err_info);
static gboolean radcom_read_rec_data(FILE_T fh, guchar *pd, int length, static gboolean radcom_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err); int *err, gchar **err_info);
int radcom_open(wtap *wth, int *err, gchar **err_info) int radcom_open(wtap *wth, int *err, gchar **err_info)
{ {
@ -111,7 +111,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(r_magic, 8, wth->fh); bytes_read = file_read(r_magic, 8, wth->fh);
if (bytes_read != 8) { if (bytes_read != 8) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -133,7 +133,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(t_magic, 11, wth->fh); bytes_read = file_read(t_magic, 11, wth->fh);
if (bytes_read != 11) { if (bytes_read != 11) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -146,7 +146,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(t_magic, 11, wth->fh); bytes_read = file_read(t_magic, 11, wth->fh);
if (bytes_read != 11) { if (bytes_read != 11) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -160,7 +160,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(&start_date, sizeof(struct frame_date), bytes_read = file_read(&start_date, sizeof(struct frame_date),
wth->fh); wth->fh);
if (bytes_read != sizeof(struct frame_date)) { if (bytes_read != sizeof(struct frame_date)) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -259,14 +259,14 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
return 1; return 1;
read_error: read_error:
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
} }
/* Read the next packet */ /* Read the next packet */
static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_, static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset) gint64 *data_offset)
{ {
int ret; int ret;
@ -280,7 +280,7 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
/* Read record header. */ /* Read record header. */
*data_offset = wth->data_offset; *data_offset = wth->data_offset;
ret = radcom_read_rec_header(wth->fh, &hdr, err); ret = radcom_read_rec_header(wth->fh, &hdr, err, err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
return FALSE; return FALSE;
@ -335,7 +335,8 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
* XXX - is this stuff a pseudo-header? * XXX - is this stuff a pseudo-header?
* The direction appears to be in the "hdr.dce" field. * The direction appears to be in the "hdr.dce" field.
*/ */
if (!radcom_read_rec_data(wth->fh, phdr, sizeof phdr, err)) if (!radcom_read_rec_data(wth->fh, phdr, sizeof phdr, err,
err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += 8; wth->data_offset += 8;
length -= 8; length -= 8;
@ -349,7 +350,7 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
*/ */
buffer_assure_space(wth->frame_buffer, length); buffer_assure_space(wth->frame_buffer, length);
if (!radcom_read_rec_data(wth->fh, if (!radcom_read_rec_data(wth->fh,
buffer_start_ptr(wth->frame_buffer), length, err)) buffer_start_ptr(wth->frame_buffer), length, err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += length; wth->data_offset += length;
@ -361,7 +362,7 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&fcs, sizeof fcs, wth->fh); bytes_read = file_read(&fcs, sizeof fcs, wth->fh);
if (bytes_read != sizeof fcs) { if (bytes_read != sizeof fcs) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -375,7 +376,7 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
static gboolean static gboolean
radcom_seek_read(wtap *wth, gint64 seek_off, radcom_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
int ret; int ret;
struct radcomrec_hdr hdr; struct radcomrec_hdr hdr;
@ -385,7 +386,7 @@ radcom_seek_read(wtap *wth, gint64 seek_off,
return FALSE; return FALSE;
/* Read record header. */ /* Read record header. */
ret = radcom_read_rec_header(wth->random_fh, &hdr, err); ret = radcom_read_rec_header(wth->random_fh, &hdr, err, err_info);
if (ret <= 0) { if (ret <= 0) {
/* Read error or EOF */ /* Read error or EOF */
if (ret == 0) { if (ret == 0) {
@ -412,7 +413,7 @@ radcom_seek_read(wtap *wth, gint64 seek_off,
* The direction appears to be in the "hdr.dce" field. * The direction appears to be in the "hdr.dce" field.
*/ */
if (!radcom_read_rec_data(wth->random_fh, phdr, sizeof phdr, if (!radcom_read_rec_data(wth->random_fh, phdr, sizeof phdr,
err)) err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
break; break;
} }
@ -420,18 +421,19 @@ radcom_seek_read(wtap *wth, gint64 seek_off,
/* /*
* Read the packet data. * Read the packet data.
*/ */
return radcom_read_rec_data(wth->random_fh, pd, length, err); return radcom_read_rec_data(wth->random_fh, pd, length, err, err_info);
} }
static int static int
radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, int *err) radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(hdr, sizeof *hdr, fh); bytes_read = file_read(hdr, sizeof *hdr, fh);
if (bytes_read != sizeof *hdr) { if (bytes_read != sizeof *hdr) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
if (bytes_read != 0) { if (bytes_read != 0) {
@ -444,7 +446,8 @@ radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, int *err)
} }
static gboolean static gboolean
radcom_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) radcom_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -452,7 +455,7 @@ radcom_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
bytes_read = file_read(pd, length, fh); bytes_read = file_read(pd, length, fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -94,12 +94,12 @@ static gboolean snoop_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info); int *err, gchar **err_info);
static gboolean snoop_read_atm_pseudoheader(FILE_T fh, static gboolean snoop_read_atm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err); union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
static gboolean snoop_read_shomiti_wireless_pseudoheader(FILE_T fh, static gboolean snoop_read_shomiti_wireless_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info,
int *header_size); int *header_size);
static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length, static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err); int *err, gchar **err_info);
static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err); const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
@ -253,7 +253,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, sizeof magic, wth->fh); bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) { if (bytes_read != sizeof magic) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -268,7 +268,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, wth->fh); bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) { if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -329,7 +329,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&rec_hdr, sizeof rec_hdr, wth->fh); bytes_read = file_read(&rec_hdr, sizeof rec_hdr, wth->fh);
if (bytes_read != sizeof rec_hdr) { if (bytes_read != sizeof rec_hdr) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
if (*err != 0) { if (*err != 0) {
@ -463,7 +463,7 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, wth->fh); bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) { if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -515,7 +515,7 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
return FALSE; return FALSE;
} }
if (!snoop_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, if (!snoop_read_atm_pseudoheader(wth->fh, &wth->pseudo_header,
err)) err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
/* /*
@ -566,7 +566,7 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
if (!snoop_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), if (!snoop_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
packet_size, err)) packet_size, err, err_info))
return FALSE; /* Read error */ return FALSE; /* Read error */
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -609,7 +609,7 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(padbuf, bytes_to_read, wth->fh); bytes_read = file_read(padbuf, bytes_to_read, wth->fh);
if (bytes_read != bytes_to_read) { if (bytes_read != bytes_to_read) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -633,7 +633,7 @@ snoop_seek_read(wtap *wth, gint64 seek_off,
case WTAP_ENCAP_ATM_PDUS: case WTAP_ENCAP_ATM_PDUS:
if (!snoop_read_atm_pseudoheader(wth->random_fh, pseudo_header, if (!snoop_read_atm_pseudoheader(wth->random_fh, pseudo_header,
err)) { err, err_info)) {
/* Read error */ /* Read error */
return FALSE; return FALSE;
} }
@ -663,7 +663,7 @@ snoop_seek_read(wtap *wth, gint64 seek_off,
/* /*
* Read the packet data. * Read the packet data.
*/ */
if (!snoop_read_rec_data(wth->random_fh, pd, length, err)) if (!snoop_read_rec_data(wth->random_fh, pd, length, err, err_info))
return FALSE; /* failed */ return FALSE; /* failed */
/* /*
@ -678,7 +678,7 @@ snoop_seek_read(wtap *wth, gint64 seek_off,
static gboolean static gboolean
snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
int *err) int *err, gchar **err_info)
{ {
struct snoop_atm_hdr atm_phdr; struct snoop_atm_hdr atm_phdr;
int bytes_read; int bytes_read;
@ -688,7 +688,7 @@ snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&atm_phdr, sizeof (struct snoop_atm_hdr), fh); bytes_read = file_read(&atm_phdr, sizeof (struct snoop_atm_hdr), fh);
if (bytes_read != sizeof (struct snoop_atm_hdr)) { if (bytes_read != sizeof (struct snoop_atm_hdr)) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -781,7 +781,7 @@ snoop_read_shomiti_wireless_pseudoheader(FILE_T fh,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&whdr, sizeof (shomiti_wireless_header), fh); bytes_read = file_read(&whdr, sizeof (shomiti_wireless_header), fh);
if (bytes_read != sizeof (shomiti_wireless_header)) { if (bytes_read != sizeof (shomiti_wireless_header)) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -825,7 +825,8 @@ snoop_read_shomiti_wireless_pseudoheader(FILE_T fh,
} }
static gboolean static gboolean
snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
gchar **err_info)
{ {
int bytes_read; int bytes_read;
@ -833,7 +834,7 @@ snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
bytes_read = file_read(pd, length, fh); bytes_read = file_read(pd, length, fh);
if (bytes_read != length) { if (bytes_read != length) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;

View File

@ -68,7 +68,7 @@ static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_of
buffer_assure_space(wth->frame_buffer, packet_size); buffer_assure_space(wth->frame_buffer, packet_size);
buf = buffer_start_ptr(wth->frame_buffer); buf = buffer_start_ptr(wth->frame_buffer);
wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err); wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info);
wth->data_offset += packet_size; wth->data_offset += packet_size;
@ -88,7 +88,7 @@ static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_of
static gboolean tnef_seek_read(wtap *wth, gint64 seek_off, static gboolean tnef_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header _U_, union wtap_pseudo_header *pseudo_header _U_,
guint8 *pd, int length, int *err, gchar **err_info _U_) guint8 *pd, int length, int *err, gchar **err_info)
{ {
int packet_size = length; int packet_size = length;
@ -101,19 +101,19 @@ static gboolean tnef_seek_read(wtap *wth, gint64 seek_off,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE; return FALSE;
wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err); wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err, err_info);
return TRUE; return TRUE;
} }
int tnef_open(wtap *wth, int *err, gchar **err_info _U_) int tnef_open(wtap *wth, int *err, gchar **err_info)
{ {
int bytes_read; int bytes_read;
guint32 magic; guint32 magic;
bytes_read = file_read(&magic, sizeof magic, wth->fh); bytes_read = file_read(&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) { if (bytes_read != sizeof magic) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return (*err != 0) ? -1 : 0; return (*err != 0) ? -1 : 0;
} }

View File

@ -122,8 +122,9 @@ static int parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
/* Seeks to the beginning of the next packet, and returns the /* Seeks to the beginning of the next packet, and returns the
byte offset. Returns -1 on failure, and sets "*err" to the error. */ byte offset. Returns -1 on failure, and sets "*err" to the error
static gint64 toshiba_seek_next_packet(wtap *wth, int *err) and "*err_info" to null or an additional error string. */
static gint64 toshiba_seek_next_packet(wtap *wth, int *err, gchar **err_info)
{ {
int byte; int byte;
guint level = 0; guint level = 0;
@ -137,7 +138,7 @@ static gint64 toshiba_seek_next_packet(wtap *wth, int *err)
cur_off = file_tell(wth->fh); cur_off = file_tell(wth->fh);
if (cur_off == -1) { if (cur_off == -1) {
/* Error. */ /* Error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return -1; return -1;
} }
return cur_off + 1; return cur_off + 1;
@ -151,7 +152,7 @@ static gint64 toshiba_seek_next_packet(wtap *wth, int *err)
*err = 0; *err = 0;
} else { } else {
/* We got an error. */ /* We got an error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
} }
return -1; return -1;
} }
@ -163,9 +164,10 @@ static gint64 toshiba_seek_next_packet(wtap *wth, int *err)
* a Toshiba trace file. * a Toshiba trace file.
* *
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error; * Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
* if we get an I/O error, "*err" will be set to a non-zero value. * if we get an I/O error, "*err" will be set to a non-zero value and
* "*err_info" will be set to null or an additional error string.
*/ */
static gboolean toshiba_check_file_type(wtap *wth, int *err) static gboolean toshiba_check_file_type(wtap *wth, int *err, gchar **err_info)
{ {
char buf[TOSHIBA_LINE_LENGTH]; char buf[TOSHIBA_LINE_LENGTH];
guint i, reclen, level, line; guint i, reclen, level, line;
@ -200,7 +202,7 @@ static gboolean toshiba_check_file_type(wtap *wth, int *err)
if (file_eof(wth->fh)) if (file_eof(wth->fh))
*err = 0; *err = 0;
else else
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; return FALSE;
} }
} }
@ -209,10 +211,10 @@ static gboolean toshiba_check_file_type(wtap *wth, int *err)
} }
int toshiba_open(wtap *wth, int *err, gchar **err_info _U_) int toshiba_open(wtap *wth, int *err, gchar **err_info)
{ {
/* Look for Toshiba header */ /* Look for Toshiba header */
if (!toshiba_check_file_type(wth, err)) { if (!toshiba_check_file_type(wth, err, err_info)) {
if (*err == 0) if (*err == 0)
return 0; return 0;
else else
@ -239,7 +241,7 @@ static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
int pkt_len; int pkt_len;
/* Find the next packet */ /* Find the next packet */
offset = toshiba_seek_next_packet(wth, err); offset = toshiba_seek_next_packet(wth, err, err_info);
if (offset < 1) if (offset < 1)
return FALSE; return FALSE;
@ -303,7 +305,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
* extract the useful information * extract the useful information
*/ */
if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) { if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -333,7 +335,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
*/ */
do { do {
if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) { if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -398,7 +400,7 @@ parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err,
for (i = 0; i < hex_lines; i++) { for (i = 0; i < hex_lines; i++) {
if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) { if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }

View File

@ -189,7 +189,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(magic, sizeof magic, wth->fh); bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) if (bytes_read != sizeof magic)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -204,7 +204,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(&vfile_hdr, sizeof vfile_hdr, wth->fh); bytes_read = file_read(&vfile_hdr, sizeof vfile_hdr, wth->fh);
if (bytes_read != sizeof vfile_hdr) if (bytes_read != sizeof vfile_hdr)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err != 0) if (*err != 0)
return -1; return -1;
return 0; return 0;
@ -319,7 +319,7 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
bytes_read = file_read(&vpkt_hdr, phdr_size, wth->fh); bytes_read = file_read(&vpkt_hdr, phdr_size, wth->fh);
if (bytes_read != phdr_size) if (bytes_read != phdr_size)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
{ {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -339,7 +339,7 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
bytes_read = file_read(&vatm_hdr, ahdr_size, wth->fh); bytes_read = file_read(&vatm_hdr, ahdr_size, wth->fh);
if (bytes_read != ahdr_size) if (bytes_read != ahdr_size)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
{ {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
@ -372,7 +372,7 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
if (bytes_read != (int) packet_size) if (bytes_read != (int) packet_size)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -478,7 +478,7 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
the direction flag works. */ the direction flag works. */
static gboolean visual_seek_read (wtap *wth, gint64 seek_off, static gboolean visual_seek_read (wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
int *err, gchar **err_info _U_) int *err, gchar **err_info)
{ {
struct visual_pkt_hdr vpkt_hdr; struct visual_pkt_hdr vpkt_hdr;
struct visual_atm_hdr vatm_hdr; struct visual_atm_hdr vatm_hdr;
@ -505,7 +505,7 @@ static gboolean visual_seek_read (wtap *wth, gint64 seek_off,
errno = WTAP_ERR_CANT_READ; errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&vpkt_hdr, phdr_size, wth->random_fh); bytes_read = file_read(&vpkt_hdr, phdr_size, wth->random_fh);
if (bytes_read != phdr_size) { if (bytes_read != phdr_size) {
*err = file_error(wth->random_fh); *err = file_error(wth->random_fh, err_info);
if (*err == 0) if (*err == 0)
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
return FALSE; return FALSE;
@ -519,7 +519,7 @@ static gboolean visual_seek_read (wtap *wth, gint64 seek_off,
bytes_read = file_read(&vatm_hdr, ahdr_size, wth->random_fh); bytes_read = file_read(&vatm_hdr, ahdr_size, wth->random_fh);
if (bytes_read != ahdr_size) if (bytes_read != ahdr_size)
{ {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) if (*err == 0 && bytes_read != 0)
{ {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;

View File

@ -166,7 +166,7 @@ static long vms_seek_next_packet(wtap *wth, int *err)
cur_off = file_tell(wth->fh); cur_off = file_tell(wth->fh);
if (cur_off == -1) { if (cur_off == -1) {
/* Error */ /* Error */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
hdr = NULL; hdr = NULL;
return -1; return -1;
} }
@ -186,7 +186,7 @@ static long vms_seek_next_packet(wtap *wth, int *err)
equivalent to "ferror()" in zlib, alas, equivalent to "ferror()" in zlib, alas,
so we don't have a wrapper to check for so we don't have a wrapper to check for
an error). */ an error). */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
} }
break; break;
} }
@ -200,12 +200,13 @@ static long vms_seek_next_packet(wtap *wth, int *err)
* a VMS trace file. * a VMS trace file.
* *
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error; * Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
* if we get an I/O error, "*err" will be set to a non-zero value. * if we get an I/O error, "*err" will be set to a non-zero value and
* "*err_info will be set to null or an additional error string.
* *
* Leaves file handle at begining of line that contains the VMS Magic * Leaves file handle at begining of line that contains the VMS Magic
* identifier. * identifier.
*/ */
static gboolean vms_check_file_type(wtap *wth, int *err) static gboolean vms_check_file_type(wtap *wth, int *err, gchar **err_info)
{ {
char buf[VMS_LINE_LENGTH]; char buf[VMS_LINE_LENGTH];
guint reclen, line; guint reclen, line;
@ -217,7 +218,7 @@ static gboolean vms_check_file_type(wtap *wth, int *err)
mpos = file_tell(wth->fh); mpos = file_tell(wth->fh);
if (mpos == -1) { if (mpos == -1) {
/* Error. */ /* Error. */
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; return FALSE;
} }
if (file_gets(buf, VMS_LINE_LENGTH, wth->fh) != NULL) { if (file_gets(buf, VMS_LINE_LENGTH, wth->fh) != NULL) {
@ -245,7 +246,7 @@ static gboolean vms_check_file_type(wtap *wth, int *err)
if (file_eof(wth->fh)) if (file_eof(wth->fh))
*err = 0; *err = 0;
else else
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; return FALSE;
} }
} }
@ -254,10 +255,10 @@ static gboolean vms_check_file_type(wtap *wth, int *err)
} }
int vms_open(wtap *wth, int *err, gchar **err_info _U_) int vms_open(wtap *wth, int *err, gchar **err_info)
{ {
/* Look for VMS header */ /* Look for VMS header */
if (!vms_check_file_type(wth, err)) { if (!vms_check_file_type(wth, err, err_info)) {
if (*err == 0) if (*err == 0)
return 0; return 0;
else else
@ -290,7 +291,7 @@ static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
offset = file_tell(wth->fh); offset = file_tell(wth->fh);
#endif #endif
if (offset < 1) { if (offset < 1) {
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; return FALSE;
} }
@ -386,7 +387,7 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info)
/* Skip lines until one starts with a hex number */ /* Skip lines until one starts with a hex number */
do { do {
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) { if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if ((*err == 0) && (csec != 101)) { if ((*err == 0) && (csec != 101)) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -463,7 +464,7 @@ parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err,
for (i = 0; i < pkt_len; i += 16) { for (i = 0; i < pkt_len; i += 16) {
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) { if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -473,7 +474,7 @@ parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err,
if (i == 0) { if (i == 0) {
while (! isdumpline(line)) { /* advance to start of hex data */ while (! isdumpline(line)) { /* advance to start of hex data */
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) { if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
*err = WTAP_ERR_SHORT_READ; *err = WTAP_ERR_SHORT_READ;
} }
@ -498,7 +499,7 @@ parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err,
* Wiretap API, we should parse those lines and return "n" as * Wiretap API, we should parse those lines and return "n" as
* a packet drop count. */ * a packet drop count. */
if (!file_gets(line, VMS_LINE_LENGTH, fh)) { if (!file_gets(line, VMS_LINE_LENGTH, fh)) {
*err = file_error(fh); *err = file_error(fh, err_info);
if (*err == 0) { if (*err == 0) {
/* There is no next line, so there's no "TCPIPtrace could not /* There is no next line, so there's no "TCPIPtrace could not
* save n packets" line; not an error. */ * save n packets" line; not an error. */

View File

@ -305,25 +305,25 @@ extern gint wtap_num_file_types;
} }
#endif #endif
#define wtap_file_read_unknown_bytes(target, num_bytes, fh, err) \ #define wtap_file_read_unknown_bytes(target, num_bytes, fh, err, err_info) \
G_STMT_START \ G_STMT_START \
{ \ { \
int _bytes_read; \ int _bytes_read; \
_bytes_read = file_read((target), (num_bytes), (fh)); \ _bytes_read = file_read((target), (num_bytes), (fh)); \
if (_bytes_read != (int) (num_bytes)) { \ if (_bytes_read != (int) (num_bytes)) { \
*(err) = file_error((fh)); \ *(err) = file_error((fh), (err_info)); \
return FALSE; \ return FALSE; \
} \ } \
} \ } \
G_STMT_END G_STMT_END
#define wtap_file_read_expected_bytes(target, num_bytes, fh, err) \ #define wtap_file_read_expected_bytes(target, num_bytes, fh, err, err_info) \
G_STMT_START \ G_STMT_START \
{ \ { \
int _bytes_read; \ int _bytes_read; \
_bytes_read = file_read((target), (num_bytes), (fh)); \ _bytes_read = file_read((target), (num_bytes), (fh)); \
if (_bytes_read != (int) (num_bytes)) { \ if (_bytes_read != (int) (num_bytes)) { \
*(err) = file_error((fh)); \ *(err) = file_error((fh), (err_info)); \
if (*(err) == 0 && _bytes_read > 0) { \ if (*(err) == 0 && _bytes_read > 0) { \
*(err) = WTAP_ERR_SHORT_READ; \ *(err) = WTAP_ERR_SHORT_READ; \
} \ } \

View File

@ -585,7 +585,10 @@ static const char *wtap_errlist[] = {
"Uncompression error: data oddly truncated", "Uncompression error: data oddly truncated",
"Uncompression error: data would overflow buffer", "Uncompression error: data would overflow buffer",
"Uncompression error: bad LZ77 offset", "Uncompression error: bad LZ77 offset",
"The standard input cannot be opened for random access" "The standard input cannot be opened for random access",
"That file format doesn't support compression",
NULL,
"Uncompression error"
}; };
#define WTAP_ERRLIST_SIZE (sizeof wtap_errlist / sizeof wtap_errlist[0]) #define WTAP_ERRLIST_SIZE (sizeof wtap_errlist / sizeof wtap_errlist[0])
@ -710,7 +713,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
* last packet of the file. * last packet of the file.
*/ */
if (*err == 0) if (*err == 0)
*err = file_error(wth->fh); *err = file_error(wth->fh, err_info);
return FALSE; /* failure */ return FALSE; /* failure */
} }

View File

@ -1002,10 +1002,12 @@ int wtap_register_encap_type(char* name, char* short_name);
/* LZ77 compressed data has bad offset to string */ /* LZ77 compressed data has bad offset to string */
#define WTAP_ERR_RANDOM_OPEN_STDIN -18 #define WTAP_ERR_RANDOM_OPEN_STDIN -18
/* We're trying to open the standard input for random access */ /* We're trying to open the standard input for random access */
#define WTAP_ERR_COMPRESSION_NOT_SUPPORTED -19 #define WTAP_ERR_COMPRESSION_NOT_SUPPORTED -19
/* The filetype doesn't support output compression */ /* The filetype doesn't support output compression */
#define WTAP_ERR_CANT_SEEK -20 #define WTAP_ERR_CANT_SEEK -20
/* An attempt to seek failed, reason unknown */ /* An attempt to seek failed, reason unknown */
#define WTAP_ERR_DECOMPRESS -21
/* Error decompressing */
/* Errors from zlib; zlib error Z_xxx turns into Wiretap error /* Errors from zlib; zlib error Z_xxx turns into Wiretap error
WTAP_ERR_ZLIB + Z_xxx. WTAP_ERR_ZLIB + Z_xxx.