From Jakub Zawadzki:

file_read(buf, bsize, count, file) macro is compilant with fread
function and takes elements count+ size of each element, however to make
it compilant with gzread() it always returns number of bytes.

In wiretap file_read() this is not really used, file_read is called
either with bsize set to 1 or count to 1.

Attached patch remove bsize argument from macro.

svn path=/trunk/; revision=36491
This commit is contained in:
Guy Harris 2011-04-06 06:51:19 +00:00
parent c039f9f8a8
commit 4c93827e34
33 changed files with 198 additions and 199 deletions

View File

@ -3246,6 +3246,7 @@ Martin Kaiser <martin [AT] kaiser.cx> {
Jakub Zawadzki <darkjames [AT] darkjames.ath.cx> {
JSON dissector
Wiretap cleanup
}
Roland Knall <rknall [AT] gmail.com> {

View File

@ -126,7 +126,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
int encap = WTAP_ENCAP_UNKNOWN;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&Capture_Header.Info_Header, 1, 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)) {
*err = file_error(wth->fh);
if (*err != 0)
@ -182,7 +182,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
}
/* read the remaining header information */
bytes_read = file_read(&Capture_Header.HeaderDateCreation, 1, 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) ) {
*err = file_error(wth->fh);
if (*err != 0)
@ -276,7 +276,7 @@ _5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(pd, 1, length, fh);
bytes_read = file_read(pd, length, fh);
if (bytes_read != length) {
*err = file_error(fh);
@ -301,7 +301,7 @@ _5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
bytes_to_read = sizeof(t_5VW_TimeStamped_Header);
/* Read record header. */
bytes_read = file_read(hdr, 1, bytes_to_read, fh);
bytes_read = file_read(hdr, bytes_to_read, fh);
if (bytes_read != bytes_to_read) {
*err = file_error(fh);
if (*err == 0 && bytes_read != 0) {

View File

@ -365,7 +365,7 @@ airopeekv9_process_header(FILE_T fh, hdr_info_t *hdr_info, int *err,
do {
/* Get the tag and value.
XXX - this assumes all values are 4 bytes long. */
bytes_read = file_read(tag_value, 1, sizeof tag_value, fh);
bytes_read = file_read(tag_value, sizeof tag_value, fh);
if (bytes_read != (int) sizeof tag_value) {
*err = file_error(fh);
if (*err == 0) {

View File

@ -126,7 +126,7 @@ int ber_open(wtap *wth, int *err, gchar **err_info _U_)
gint64 file_size;
int offset = 0, i;
bytes_read = file_read(&bytes, 1, BER_BYTES_TO_CHECK, wth->fh);
bytes_read = file_read(&bytes, BER_BYTES_TO_CHECK, wth->fh);
if (bytes_read != BER_BYTES_TO_CHECK) {
*err = file_error(wth->fh);
return (*err != 0) ? -1 : 0;

View File

@ -90,7 +90,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info _U_)
/* Read in the string that should be at the start of a "btsnoop" file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
*err = file_error(wth->fh);
if (*err != 0)
@ -105,7 +105,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info _U_)
/* Read the rest of the header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh);
if (*err != 0)
@ -172,7 +172,7 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
/* Read record header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0)
@ -246,7 +246,7 @@ static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
/* Read record header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->random_fh);
bytes_read = file_read(&hdr, sizeof hdr, wth->random_fh);
if (bytes_read != sizeof hdr) {
*err = file_error(wth->random_fh);
if (*err == 0 && bytes_read != 0)
@ -293,7 +293,7 @@ snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(pd, 1, length, fh);
bytes_read = file_read(pd, length, fh);
if (bytes_read != length) {
*err = file_error(fh);

View File

@ -167,7 +167,7 @@ commview_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset)
}
buffer_assure_space(wth->frame_buffer, cv_hdr.data_len);
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), 1,
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer),
cv_hdr.data_len, wth->fh);
if(bytes_read != cv_hdr.data_len) {
*err = file_error(wth->fh);
@ -227,7 +227,7 @@ commview_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
pseudo_header->ieee_802_11.signal_level = cv_hdr.signal_level_percent;
}
bytes_read = file_read(pd, 1, 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) {
*err = file_error(wth->random_fh);
if(*err == 0)
@ -244,24 +244,24 @@ commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err)
{
int bytes_read = 0;
bytes_read += file_read(&cv_hdr->data_len, 2, 1, fh);
bytes_read += file_read(&cv_hdr->source_data_len, 2, 1, fh);
bytes_read += file_read(&cv_hdr->version, 1, 1, fh);
bytes_read += file_read(&cv_hdr->year, 2, 1, fh);
bytes_read += file_read(&cv_hdr->month, 1, 1, fh);
bytes_read += file_read(&cv_hdr->day, 1, 1, fh);
bytes_read += file_read(&cv_hdr->hours, 1, 1, fh);
bytes_read += file_read(&cv_hdr->minutes, 1, 1, fh);
bytes_read += file_read(&cv_hdr->seconds, 1, 1, fh);
bytes_read += file_read(&cv_hdr->usecs, 4, 1, fh);
bytes_read += file_read(&cv_hdr->flags, 1, 1, fh);
bytes_read += file_read(&cv_hdr->signal_level_percent, 1, 1, fh);
bytes_read += file_read(&cv_hdr->rate, 1, 1, fh);
bytes_read += file_read(&cv_hdr->band, 1, 1, fh);
bytes_read += file_read(&cv_hdr->channel, 1, 1, fh);
bytes_read += file_read(&cv_hdr->direction, 1, 1, fh);
bytes_read += file_read(&cv_hdr->signal_level_dbm, 1, 1, fh);
bytes_read += file_read(&cv_hdr->noise_level, 1, 1, fh);
bytes_read += file_read(&cv_hdr->data_len, 2, fh);
bytes_read += file_read(&cv_hdr->source_data_len, 2, fh);
bytes_read += file_read(&cv_hdr->version, 1, fh);
bytes_read += file_read(&cv_hdr->year, 2, fh);
bytes_read += file_read(&cv_hdr->month, 1, fh);
bytes_read += file_read(&cv_hdr->day, 1, fh);
bytes_read += file_read(&cv_hdr->hours, 1, fh);
bytes_read += file_read(&cv_hdr->minutes, 1, fh);
bytes_read += file_read(&cv_hdr->seconds, 1, fh);
bytes_read += file_read(&cv_hdr->usecs, 4, fh);
bytes_read += file_read(&cv_hdr->flags, 1, fh);
bytes_read += file_read(&cv_hdr->signal_level_percent, 1, fh);
bytes_read += file_read(&cv_hdr->rate, 1, fh);
bytes_read += file_read(&cv_hdr->band, 1, fh);
bytes_read += file_read(&cv_hdr->channel, 1, fh);
bytes_read += file_read(&cv_hdr->direction, 1, fh);
bytes_read += file_read(&cv_hdr->signal_level_dbm, 1, fh);
bytes_read += file_read(&cv_hdr->noise_level, 1, fh);
/* Convert multi-byte values from little endian to host endian format */
cv_hdr->data_len = GUINT16_FROM_LE(cv_hdr->data_len);

View File

@ -78,7 +78,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
csids_t *csids;
/* check the file to make sure it is a csids file. */
bytesRead = file_read( &hdr, 1, sizeof( struct csids_header), wth->fh );
bytesRead = file_read( &hdr, sizeof( struct csids_header), wth->fh );
if( bytesRead != sizeof( struct csids_header) ) {
*err = file_error( wth->fh );
if( *err != 0 ) {
@ -92,7 +92,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
}
hdr.seconds = pntohl( &hdr.seconds );
hdr.caplen = pntohs( &hdr.caplen );
bytesRead = file_read( &tmp, 1, 2, wth->fh );
bytesRead = file_read( &tmp, 2, wth->fh );
if( bytesRead != 2 ) {
*err = file_error( wth->fh );
if( *err != 0 ) {
@ -101,7 +101,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
return 0;
}
}
bytesRead = file_read( &iplen, 1, 2, wth->fh );
bytesRead = file_read( &iplen, 2, wth->fh );
if( bytesRead != 2 ) {
*err = file_error( wth->fh );
if( *err != 0 ) {
@ -161,7 +161,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
*data_offset = wth->data_offset;
bytesRead = file_read( &hdr, 1, sizeof( struct csids_header) , wth->fh );
bytesRead = file_read( &hdr, sizeof( struct csids_header) , wth->fh );
if( bytesRead != sizeof( struct csids_header) ) {
*err = file_error( wth->fh );
if (*err == 0 && bytesRead != 0)
@ -177,7 +177,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
buffer_assure_space(wth->frame_buffer, hdr.caplen);
buf = buffer_start_ptr(wth->frame_buffer);
bytesRead = file_read( buf, 1, hdr.caplen, wth->fh );
bytesRead = file_read( buf, hdr.caplen, wth->fh );
if( bytesRead != hdr.caplen ) {
*err = file_error( wth->fh );
if (*err == 0)
@ -218,7 +218,7 @@ csids_seek_read (wtap *wth,
if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 )
return FALSE;
bytesRead = file_read( &hdr, 1, sizeof( struct csids_header), wth->random_fh );
bytesRead = file_read( &hdr, sizeof( struct csids_header), wth->random_fh );
if( bytesRead != sizeof( struct csids_header) ) {
*err = file_error( wth->random_fh );
if( *err == 0 ) {
@ -236,7 +236,7 @@ csids_seek_read (wtap *wth,
return FALSE;
}
bytesRead = file_read( pd, 1, hdr.caplen, wth->random_fh );
bytesRead = file_read( pd, hdr.caplen, wth->random_fh );
if( bytesRead != hdr.caplen ) {
*err = file_error( wth->random_fh );
if( *err == 0 ) {

View File

@ -104,7 +104,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
for (i = 0; i < records_for_erf_check; i++) { /* records_for_erf_check */
r = file_read(&header,1,sizeof(header),wth->fh);
r = file_read(&header,sizeof(header),wth->fh);
if (r == 0 ) break;
if (r != sizeof(header)) {
@ -177,7 +177,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
/* Read over the extension headers */
type = header.type;
while (type & 0x80){
if (file_read(&erf_ext_header, 1, 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);
return -1;
}
@ -196,7 +196,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
case ERF_TYPE_MC_AAL2:
case ERF_TYPE_COLOR_MC_HDLC_POS:
case ERF_TYPE_AAL2: /* not an MC type but has a similar 'AAL2 ext' header */
if (file_read(&mc_hdr,1,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);
return -1;
}
@ -205,7 +205,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
case ERF_TYPE_ETH:
case ERF_TYPE_COLOR_ETH:
case ERF_TYPE_DSM_COLOR_ETH:
if (file_read(&eth_hdr,1,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);
return -1;
}
@ -225,7 +225,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
return 0;
}
buffer=g_malloc(packet_size);
r = file_read(buffer, 1, packet_size, wth->fh);
r = file_read(buffer, packet_size, wth->fh);
g_free(buffer);
if (r != packet_size) {

View File

@ -141,7 +141,7 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info _U_)
/* Look for eyesdn header */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&magic, 1, sizeof magic, wth->fh);
bytes_read = file_read(&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
*err = file_error(wth->fh);
if (*err != 0)

View File

@ -32,8 +32,7 @@ extern int file_error(void *fh);
extern FILE_T file_open(const char *path, const char *mode);
#define filed_open gzdopen
/* XX: gzread and gzwrite return number of *bytes* (not number of elements) */
#define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize)))
#define file_read(buf, count, file) gzread((file),(buf),(unsigned)(count))
#define file_close gzclose
#define file_getc gzgetc
#define file_gets(buf, len, file) gzgets((file), (buf), (len))
@ -43,8 +42,7 @@ extern FILE_T file_open(const char *path, const char *mode);
#define file_open(path, mode) ws_fopen(path, mode)
#define filed_open fdopen
/* XX: file_read defined to return number of *bytes* to be consistent with gzread */
#define file_read(buf, bsize, count, file) ((bsize) * fread((buf), (bsize), (count), (file)))
#define file_read(buf, count, file) fread((buf), (1), (count), (file))
#define file_close fclose
#define file_getc fgetc
#define file_gets fgets

View File

@ -47,7 +47,7 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
*data_offset = wth->data_offset;
bytes_read = file_read(&dh, 1, DUMP_HDR_SIZE, wth->fh);
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->fh);
if (bytes_read != DUMP_HDR_SIZE) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0)
@ -71,7 +71,7 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, packet_size);
buf = buffer_start_ptr(wth->frame_buffer);
bytes_read = file_read(buf, 1, packet_size, wth->fh);
bytes_read = file_read(buf, packet_size, wth->fh);
if (bytes_read != packet_size) {
*err = file_error(wth->fh);
if (*err == 0)
@ -100,7 +100,7 @@ static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
bytes_read = file_read(&dh, 1, DUMP_HDR_SIZE, wth->random_fh);
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->random_fh);
if (bytes_read != DUMP_HDR_SIZE) {
*err = file_error(wth->random_fh);
if (*err == 0 && bytes_read != 0)
@ -108,7 +108,7 @@ static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
return FALSE;
}
bytes_read = file_read(pd, 1, length, wth->random_fh);
bytes_read = file_read(pd, length, wth->random_fh);
if (bytes_read != length) {
*err = file_error(wth->random_fh);
if (*err == 0)
@ -127,7 +127,7 @@ int hcidump_open(wtap *wth, int *err, gchar **err_info _U_)
guint8 type;
int bytes_read;
bytes_read = file_read(&dh, 1, DUMP_HDR_SIZE, wth->fh);
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->fh);
if (bytes_read != DUMP_HDR_SIZE) {
*err = file_error(wth->fh);
return (*err != 0) ? -1 : 0;
@ -137,7 +137,7 @@ int hcidump_open(wtap *wth, int *err, gchar **err_info _U_)
|| GUINT16_FROM_LE(dh.len) < 1)
return 0;
bytes_read = file_read(&type, 1, 1, wth->fh);
bytes_read = file_read(&type, 1, wth->fh);
if (bytes_read != 1) {
*err = file_error(wth->fh);
return (*err != 0) ? -1 : 0;

View File

@ -65,7 +65,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_)
/* I4B trace files have no magic in the header... Sigh */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof(hdr), wth->fh);
bytes_read = file_read(&hdr, sizeof(hdr), wth->fh);
if (bytes_read != sizeof(hdr)) {
*err = file_error(wth->fh);
if (*err != 0)
@ -222,7 +222,7 @@ i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(hdr, 1, sizeof *hdr, fh);
bytes_read = file_read(hdr, sizeof *hdr, fh);
if (bytes_read != sizeof *hdr) {
*err = file_error(fh);
if (*err != 0)
@ -262,7 +262,7 @@ i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(pd, 1, length, fh);
bytes_read = file_read(pd, length, fh);
if (bytes_read != length) {
*err = file_error(fh);

View File

@ -58,7 +58,7 @@ int iptrace_open(wtap *wth, int *err, gchar **err_info _U_)
char name[12];
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(name, 1, 11, wth->fh);
bytes_read = file_read(name, 11, wth->fh);
if (bytes_read != 11) {
*err = file_error(wth->fh);
if (*err != 0)
@ -448,7 +448,7 @@ iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(header, 1, header_len, fh);
bytes_read = file_read(header, header_len, fh);
if (bytes_read != header_len) {
*err = file_error(fh);
if (*err != 0)
@ -468,7 +468,7 @@ iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, int packet_size, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read( data_ptr, 1, packet_size, fh );
bytes_read = file_read( data_ptr, packet_size, fh );
if (bytes_read != packet_size) {
*err = file_error(fh);

View File

@ -176,7 +176,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info _U_)
* Check that file starts with a valid iSeries COMMS TRACE header
*/
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read (&magic, 1, sizeof magic, wth->fh);
bytes_read = file_read (&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic)
{
*err = file_error (wth->fh);

View File

@ -131,7 +131,7 @@ jpeg_jfif_open(wtap *wth, int *err, gchar **err_info)
int ret = 0;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic_buf, 1, sizeof(magic_buf), wth->fh);
bytes_read = file_read(magic_buf, sizeof(magic_buf), wth->fh);
if (bytes_read != (int) sizeof(magic_buf)) {
*err = file_error(wth->fh);
if (*err != 0) {

View File

@ -291,7 +291,7 @@ static gint get_record(guint8** bufferp, FILE* fh, gint64 file_offset,
if ( junky_offset == 0x2000 ) {
/* the length of the record is 0x10 bytes ahead from we are reading */
bytes_read = file_read(junk,1,0x14,fh);
bytes_read = file_read(junk,0x14,fh);
if (bytes_read == 2 && junk[0] == 0xff && junk[1] == 0xff) {
K12_DBG(1,("get_record: EOF"));
@ -308,7 +308,7 @@ static gint get_record(guint8** bufferp, FILE* fh, gint64 file_offset,
memcpy(buffer,&(junk[0x10]),4);
} else {
/* the length of the record is right where we are reading */
bytes_read = file_read(buffer,1, 0x4, fh);
bytes_read = file_read(buffer, 0x4, fh);
if (bytes_read == 2 && buffer[0] == 0xff && buffer[1] == 0xff) {
K12_DBG(1,("get_record: EOF"));
@ -345,7 +345,7 @@ static gint get_record(guint8** bufferp, FILE* fh, gint64 file_offset,
K12_DBG(6,("get_record: looping left=%d junky_offset=%" G_GINT64_MODIFIER "d",left,junky_offset));
if (junky_offset > left) {
bytes_read += last_read = file_read(writep,1, left, fh);
bytes_read += last_read = file_read(writep, left, fh);
if ( last_read != left ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR"));
@ -359,7 +359,7 @@ static gint get_record(guint8** bufferp, FILE* fh, gint64 file_offset,
return bytes_read;
}
} else {
bytes_read += last_read = file_read(writep,1, junky_offset, fh);
bytes_read += last_read = file_read(writep, junky_offset, fh);
if ( last_read != junky_offset ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR, read=%d expected=%d",last_read, junky_offset));
@ -372,7 +372,7 @@ static gint get_record(guint8** bufferp, FILE* fh, gint64 file_offset,
writep += last_read;
bytes_read += last_read = file_read(junk,1, 0x10, fh);
bytes_read += last_read = file_read(junk, 0x10, fh);
if ( last_read != 0x10 ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR"));
@ -683,7 +683,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
K12_DBG(1,("k12_open: ENTER debug_level=%u",debug_level));
#endif
if ( file_read(header_buffer,1,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"));
*err = file_error(wth->fh);
if (*err != 0) {

View File

@ -142,8 +142,8 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
lanalyzer_t *lanalyzer;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(LE_record_type, 1, 2, wth->fh);
bytes_read += file_read(LE_record_length, 1, 2, wth->fh);
bytes_read = file_read(LE_record_type, 2, wth->fh);
bytes_read += file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 4) {
*err = file_error(wth->fh);
if (*err != 0)
@ -177,8 +177,8 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
}
wth->data_offset += record_length;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(LE_record_type, 1, 2, wth->fh);
bytes_read += file_read(LE_record_length, 1, 2, wth->fh);
bytes_read = file_read(LE_record_type, 2, wth->fh);
bytes_read += file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 4) {
*err = file_error(wth->fh);
if (*err != 0) {
@ -198,7 +198,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
/* Trace Summary Record */
case RT_Summary:
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(summary, 1, sizeof summary,
bytes_read = file_read(summary, sizeof summary,
wth->fh);
if (bytes_read != sizeof summary) {
*err = file_error(wth->fh);
@ -293,7 +293,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
/* read the record type and length. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(LE_record_type, 1, 2, wth->fh);
bytes_read = file_read(LE_record_type, 2, wth->fh);
if (bytes_read != 2) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0) {
@ -302,7 +302,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
return FALSE;
}
wth->data_offset += 2;
bytes_read = file_read(LE_record_length, 1, 2, wth->fh);
bytes_read = file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 2) {
*err = file_error(wth->fh);
if (*err == 0)
@ -329,7 +329,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
/* Read the descriptor data */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(descriptor, 1, DESCRIPTOR_LEN, wth->fh);
bytes_read = file_read(descriptor, DESCRIPTOR_LEN, wth->fh);
if (bytes_read != DESCRIPTOR_LEN) {
*err = file_error(wth->fh);
if (*err == 0)
@ -342,7 +342,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, packet_size);
*data_offset = wth->data_offset;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), 1,
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer),
packet_size, wth->fh);
if (bytes_read != packet_size) {
@ -414,7 +414,7 @@ static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
/*
* Read the packet data.
*/
bytes_read = file_read(pd, sizeof(guint8), length, wth->random_fh);
bytes_read = file_read(pd, length, wth->random_fh);
if (bytes_read != length) {
*err = file_error(wth->random_fh);
if (*err == 0)

View File

@ -93,7 +93,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
/* Read in the number that should be at the start of a "libpcap" file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&magic, 1, sizeof magic, wth->fh);
bytes_read = file_read(&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
*err = file_error(wth->fh);
if (*err != 0)
@ -164,7 +164,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
/* Read the rest of the header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh);
if (*err != 0)
@ -787,7 +787,7 @@ static int libpcap_read_header(wtap *wth, int *err, gchar **err_info,
g_assert_not_reached();
bytes_to_read = 0;
}
bytes_read = file_read(hdr, 1, bytes_to_read, wth->fh);
bytes_read = file_read(hdr, bytes_to_read, wth->fh);
if (bytes_read != bytes_to_read) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0) {
@ -880,7 +880,7 @@ libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(pd, 1, length, fh);
bytes_read = file_read(pd, length, fh);
if (bytes_read != length) {
*err = file_error(fh);

View File

@ -81,7 +81,7 @@ mpeg_read_header(wtap *wth, int *err, gchar **err_info _U_,
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(n, 1, sizeof *n, wth->fh);
bytes_read = file_read(n, sizeof *n, wth->fh);
if (bytes_read != sizeof *n) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0)
@ -100,7 +100,7 @@ mpeg_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(pd, 1, length, fh);
bytes_read = file_read(pd, length, fh);
if (bytes_read != length) {
*err = file_error(fh);
@ -134,7 +134,7 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
if (file_seek(wth->fh, 3, SEEK_CUR, err) == -1)
return FALSE;
bytes_read = file_read(&stream, 1, sizeof stream, wth->fh);
bytes_read = file_read(&stream, sizeof stream, wth->fh);
if (bytes_read != sizeof stream) {
*err = file_error(wth->fh);
return FALSE;
@ -146,14 +146,14 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
guint64 pack;
guint8 stuffing;
bytes_read = file_read(&pack1, 1, sizeof pack1, wth->fh);
bytes_read = file_read(&pack1, sizeof pack1, wth->fh);
if (bytes_read != sizeof pack1) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
bytes_read = file_read(&pack0, 1, sizeof pack0, wth->fh);
bytes_read = file_read(&pack0, sizeof pack0, wth->fh);
if (bytes_read != sizeof pack0) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0)
@ -167,7 +167,7 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
if (file_seek(wth->fh, 1, SEEK_CUR, err) == -1)
return FALSE;
bytes_read = file_read(&stuffing,
1, sizeof stuffing, wth->fh);
sizeof stuffing, wth->fh);
if (bytes_read != sizeof stuffing) {
*err = file_error(wth->fh);
return FALSE;
@ -196,7 +196,7 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
}
} else {
guint16 length;
bytes_read = file_read(&length, 1, sizeof length, wth->fh);
bytes_read = file_read(&length, sizeof length, wth->fh);
if (bytes_read != sizeof length) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0)
@ -269,7 +269,7 @@ mpeg_open(wtap *wth, int *err, gchar **err_info _U_)
mpeg_t *mpeg;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic_buf, 1, sizeof magic_buf, wth->fh);
bytes_read = file_read(magic_buf, sizeof magic_buf, wth->fh);
if (bytes_read != (int) sizeof magic_buf) {
*err = file_error(wth->fh);
if (*err != 0)

View File

@ -206,7 +206,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a Network
* Monitor file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
*err = file_error(wth->fh);
if (*err != 0)
@ -221,7 +221,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
/* Read the rest of the header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh);
if (*err != 0)
@ -339,7 +339,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
}
frame_table = g_malloc(frame_table_length);
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(frame_table, 1, frame_table_length, wth->fh);
bytes_read = file_read(frame_table, frame_table_length, wth->fh);
if ((guint32)bytes_read != frame_table_length) {
*err = file_error(wth->fh);
if (*err == 0)
@ -435,7 +435,7 @@ again:
}
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, hdr_size, wth->fh);
bytes_read = file_read(&hdr, hdr_size, wth->fh);
if (bytes_read != hdr_size) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0) {
@ -584,7 +584,7 @@ again:
}
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&trlr, 1, trlr_size, wth->fh);
bytes_read = file_read(&trlr, trlr_size, wth->fh);
if (bytes_read != trlr_size) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0) {
@ -701,7 +701,7 @@ netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
guint16 vpi, vci;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&atm_phdr, 1, 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)) {
*err = file_error(fh);
if (*err == 0)
@ -732,7 +732,7 @@ netmon_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(pd, 1, length, fh);
bytes_read = file_read(pd, length, fh);
if (bytes_read != length) {
*err = file_error(fh);

View File

@ -488,7 +488,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
return 0;
}
bytes_read = file_read(nstrace_buf, 1, page_size, wth->fh);
bytes_read = file_read(nstrace_buf, page_size, wth->fh);
if (bytes_read != page_size)
{
*err = file_error(wth->fh);
@ -525,7 +525,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
}
/* Read the first page of data */
bytes_read = file_read(nstrace_buf, 1, page_size, wth->fh);
bytes_read = file_read(nstrace_buf, page_size, wth->fh);
if (bytes_read != page_size)
{
*err = file_error(wth->fh);
@ -567,7 +567,7 @@ nspm_signature_version(wtap *wth, gchar *nstrace_buf, gint32 len)
gchar *dp = nstrace_buf;
int bytes_read;
bytes_read = file_read(dp, 1, len, wth->fh);
bytes_read = file_read(dp, len, wth->fh);
if (bytes_read == len) {
for ( ; len > (gint32)(MIN(sizeof(NSPR_SIGSTR_V10), sizeof(NSPR_SIGSTR_V20))); dp++, len--)
@ -633,7 +633,7 @@ nspm_signature_version(wtap *wth, gchar *nstrace_buf, gint32 len)
nstrace_buf_offset = 0;\
wth->data_offset += nstrace_buflen;\
nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - wth->data_offset));\
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, 1, nstrace_buflen, wth->fh)) && bytes_read == nstrace_buflen); \
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && bytes_read == nstrace_buflen); \
return FALSE;\
}
@ -775,7 +775,7 @@ gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_of
nstrace_buf_offset = 0;
wth->data_offset += nstrace_buflen;
nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - wth->data_offset));
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, 1, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
return FALSE;
}
@ -916,7 +916,7 @@ gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_of
nstrace_buf_offset = 0;
wth->data_offset += nstrace_buflen;
nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - wth->data_offset));
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, 1, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
return FALSE;
}
@ -965,7 +965,7 @@ gboolean nstrace_seek_read(wtap *wth, gint64 seek_off,
/*
** Read the packet data.
*/
bytes_read = file_read(pd, 1, length, wth->random_fh);
bytes_read = file_read(pd, length, wth->random_fh);
if (bytes_read != length)
return FALSE;

View File

@ -204,7 +204,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
/* Read in the string that should be at the start of a HP file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(file_hdr.magic, 1, MAGIC_SIZE, wth->fh);
bytes_read = file_read(file_hdr.magic, MAGIC_SIZE, wth->fh);
if (bytes_read != MAGIC_SIZE) {
*err = file_error(wth->fh);
if (*err != 0)
@ -218,7 +218,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
}
/* Read the rest of the file header */
bytes_read = file_read(file_hdr.file_name, 1, FILE_HDR_SIZE - MAGIC_SIZE,
bytes_read = file_read(file_hdr.file_name, FILE_HDR_SIZE - MAGIC_SIZE,
wth->fh);
if (bytes_read != FILE_HDR_SIZE - MAGIC_SIZE) {
*err = file_error(wth->fh);
@ -240,7 +240,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
wth->snapshot_length = 0; /* not available */
/* read the first header to take a guess at the file encap */
bytes_read = file_read(dummy, 1, 4, wth->fh);
bytes_read = file_read(dummy, 4, wth->fh);
if (bytes_read != 4) {
if (*err != 0) {
wth->priv = NULL;
@ -391,7 +391,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
guint8 dummyc[16];
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&rec_hdr.hdr_len, 1, 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) {
*err = file_error(fh);
if (*err != 0)
@ -410,7 +410,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
hdr_len);
return -1;
}
bytes_read = file_read(&rec_hdr.subsys, 1, 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) {
*err = file_error(fh);
if (*err == 0)
@ -504,7 +504,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
padlen = 0;
} else {
/* outbound appears to have variable padding */
bytes_read = file_read(dummyc, 1, 9, fh);
bytes_read = file_read(dummyc, 9, fh);
if (bytes_read != 9) {
*err = file_error(fh);
if (*err == 0)
@ -557,7 +557,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
we assumes everything is. We will crash and burn for anything else */
/* for encapsulated 100baseT we do this */
phdr->pkt_encap = WTAP_ENCAP_NETTL_ETHERNET;
bytes_read = file_read(&drv_eth_hdr, 1, 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) {
*err = file_error(fh);
if (*err == 0)
@ -657,12 +657,12 @@ nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, gboolean fddiha
if (fddihack == TRUE) {
/* read in FC, dest, src, DSAP and SSAP */
if (file_read(pd, 1, 15, fh) == 15) {
if (file_read(pd, 15, fh) == 15) {
if (pd[13] == 0xAA) {
/* it's SNAP, have to eat 3 bytes??? */
if (file_read(dummy, 1, 3, fh) == 3) {
if (file_read(dummy, 3, fh) == 3) {
p=pd+15;
bytes_read = file_read(p, 1, length-18, fh);
bytes_read = file_read(p, length-18, fh);
bytes_read += 18;
} else {
bytes_read = -1;
@ -670,13 +670,13 @@ nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, gboolean fddiha
} else {
/* not SNAP */
p=pd+15;
bytes_read = file_read(p, 1, length-15, fh);
bytes_read = file_read(p, length-15, fh);
bytes_read += 15;
}
} else
bytes_read = -1;
} else
bytes_read = file_read(pd, 1, length, fh);
bytes_read = file_read(pd, length, fh);
if (bytes_read != length) {
*err = file_error(fh);

View File

@ -116,7 +116,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
offset = 0;
/* read in the buffer file header */
bytes_read = file_read(&file_header, sizeof file_header, 1, wth->fh);
bytes_read = file_read(&file_header, sizeof file_header, wth->fh);
if (bytes_read != sizeof file_header) {
*err = file_error(wth->fh);
if (*err != 0)
@ -140,7 +140,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
/* process extra information */
for (i = 0; i < file_header.number_of_information_elements; i++) {
/* read the TLV header */
bytes_read = file_read(&tlvh, sizeof tlvh, 1, wth->fh);
bytes_read = file_read(&tlvh, sizeof tlvh, wth->fh);
if (bytes_read != sizeof tlvh) {
*err = file_error(wth->fh);
if (*err == 0)
@ -182,7 +182,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
}
/* pull off the packet header */
bytes_read = file_read(&packet_header, sizeof packet_header, 1, wth->fh);
bytes_read = file_read(&packet_header, sizeof packet_header, wth->fh);
if (bytes_read != sizeof packet_header) {
*err = file_error(wth->fh);
if (*err != 0)
@ -346,7 +346,7 @@ read_packet_header(FILE_T fh, packet_entry_header *packet_header, int *err,
offset = 0;
/* pull off the packet header */
bytes_read = file_read(packet_header, sizeof *packet_header, 1, fh);
bytes_read = file_read(packet_header, sizeof *packet_header, fh);
if (bytes_read != sizeof *packet_header) {
*err = file_error(fh);
if (*err != 0)
@ -396,7 +396,7 @@ read_packet_header(FILE_T fh, packet_entry_header *packet_header, int *err,
/* process extra information */
for (i = 0; i < packet_header->number_of_information_elements; i++) {
/* read the TLV header */
bytes_read = file_read(&tlvh, sizeof tlvh, 1, fh);
bytes_read = file_read(&tlvh, sizeof tlvh, fh);
if (bytes_read != sizeof tlvh) {
*err = file_error(fh);
if (*err == 0)

View File

@ -381,7 +381,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a NetXRay
* file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
*err = file_error(wth->fh);
if (*err != 0)
@ -400,7 +400,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
/* Read the rest of the header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh);
if (*err != 0)
@ -1102,7 +1102,7 @@ netxray_read_rec_header(wtap *wth, FILE_T fh, union netxrayrec_hdr *hdr,
break;
}
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(hdr, 1, hdr_size, fh);
bytes_read = file_read(hdr, hdr_size, fh);
if (bytes_read != hdr_size) {
*err = file_error(wth->fh);
if (*err != 0)
@ -1451,7 +1451,7 @@ netxray_read_rec_data(FILE_T fh, guint8 *data_ptr, guint32 packet_size,
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(data_ptr, 1, packet_size, fh);
bytes_read = file_read(data_ptr, packet_size, fh);
if (bytes_read <= 0 || (guint32)bytes_read != packet_size) {
*err = file_error(fh);

View File

@ -557,7 +557,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a Sniffer file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
*err = file_error(wth->fh);
if (*err != 0)
@ -575,8 +575,8 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
* record.
*/
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(record_type, 1, 2, wth->fh);
bytes_read += file_read(record_length, 1, 4, wth->fh);
bytes_read = file_read(record_type, 2, wth->fh);
bytes_read += file_read(record_length, 4, wth->fh);
if (bytes_read != 6) {
*err = file_error(wth->fh);
if (*err != 0)
@ -595,7 +595,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
}
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&version, 1, sizeof version, wth->fh);
bytes_read = file_read(&version, sizeof version, wth->fh);
if (bytes_read != sizeof version) {
*err = file_error(wth->fh);
if (*err != 0)
@ -780,7 +780,7 @@ process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers,
for (;;) {
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(record_type, 1, 2, wth->fh);
bytes_read = file_read(record_type, 2, wth->fh);
if (bytes_read != 2) {
*err = file_error(wth->fh);
if (*err != 0)
@ -811,7 +811,7 @@ process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers,
}
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(record_length, 1, 4, wth->fh);
bytes_read = file_read(record_length, 4, wth->fh);
if (bytes_read != 4) {
*err = file_error(wth->fh);
if (*err == 0)
@ -839,7 +839,7 @@ process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers,
* record data.
*/
bytes_to_read = MIN(length, (int)sizeof buffer);
bytes_read = file_read(buffer, 1, bytes_to_read,
bytes_read = file_read(buffer, bytes_to_read,
wth->fh);
if (bytes_read != bytes_to_read) {
*err = file_error(wth->fh);
@ -2437,7 +2437,7 @@ ng_file_read(void *buffer, size_t elementsize, size_t numelements, wtap *wth,
if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED) {
errno = WTAP_ERR_CANT_READ;
copied_bytes = file_read(buffer, 1, copybytes, infile);
copied_bytes = file_read(buffer, copybytes, infile);
if ((size_t) copied_bytes != copybytes)
*err = file_error(infile);
return copied_bytes;
@ -2540,7 +2540,7 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err)
/* Read one 16-bit word which is length of next compressed blob */
errno = WTAP_ERR_CANT_READ;
read_len = file_read(&blob_len, 1, 2, infile);
read_len = file_read(&blob_len, 2, infile);
if (2 != read_len) {
*err = file_error(infile);
return -1;
@ -2562,7 +2562,7 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err)
/* Read the blob */
errno = WTAP_ERR_CANT_READ;
read_len = file_read(file_inbuf, 1, in_len, infile);
read_len = file_read(file_inbuf, in_len, infile);
if ((size_t) in_len != read_len) {
*err = file_error(infile);
g_free(file_inbuf);

View File

@ -68,7 +68,7 @@ int packetlogger_open(wtap *wth, int *err, gchar **err_info _U_)
if(!packetlogger_read_header(&pl_hdr, wth->fh, err))
return -1;
if (file_read(&type, 1, 1, wth->fh) <= 0)
if (file_read(&type, 1, wth->fh) <= 0)
return -1;
/* Verify this file belongs to us */
@ -110,7 +110,7 @@ packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
}
buffer_assure_space(wth->frame_buffer, pl_hdr.len - 8);
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), 1,
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer),
pl_hdr.len - 8,
wth->fh);
if(bytes_read != pl_hdr.len - 8) {
@ -156,7 +156,7 @@ packetlogger_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
return FALSE;
}
bytes_read = file_read(pd, 1, 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)) {
*err = file_error(wth->random_fh);
if(*err == 0)
@ -173,8 +173,8 @@ packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, int *err)
{
guint bytes_read = 0;
bytes_read += file_read(&pl_hdr->len, 4, 1, fh);
bytes_read += file_read(&pl_hdr->ts, 8, 1, fh);
bytes_read += file_read(&pl_hdr->len, 4, fh);
bytes_read += file_read(&pl_hdr->ts, 8, fh);
/* Convert multi-byte values from big endian to host endian */
pl_hdr->len = GUINT32_FROM_BE(pl_hdr->len);

View File

@ -718,7 +718,7 @@ pcap_read_sunatm_pseudoheader(FILE_T fh,
guint16 vci;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(atm_phdr, 1, SUNATM_LEN, fh);
bytes_read = file_read(atm_phdr, SUNATM_LEN, fh);
if (bytes_read != SUNATM_LEN) {
*err = file_error(fh);
if (*err == 0)
@ -806,7 +806,7 @@ pcap_read_nokiaatm_pseudoheader(FILE_T fh,
guint16 vci;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(atm_phdr, 1, NOKIAATM_LEN, fh);
bytes_read = file_read(atm_phdr, NOKIAATM_LEN, fh);
if (bytes_read != NOKIAATM_LEN) {
*err = file_error(fh);
if (*err == 0)
@ -839,7 +839,7 @@ pcap_read_irda_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(irda_phdr, 1, IRDA_SLL_LEN, fh);
bytes_read = file_read(irda_phdr, IRDA_SLL_LEN, fh);
if (bytes_read != IRDA_SLL_LEN) {
*err = file_error(fh);
if (*err == 0)
@ -866,7 +866,7 @@ pcap_read_mtp2_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(mtp2_hdr, 1, MTP2_HDR_LEN, fh);
bytes_read = file_read(mtp2_hdr, MTP2_HDR_LEN, fh);
if (bytes_read != MTP2_HDR_LEN) {
*err = file_error(fh);
if (*err == 0)
@ -889,7 +889,7 @@ pcap_read_lapd_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(lapd_phdr, 1, LAPD_SLL_LEN, fh);
bytes_read = file_read(lapd_phdr, LAPD_SLL_LEN, fh);
if (bytes_read != LAPD_SLL_LEN) {
*err = file_error(fh);
if (*err == 0)
@ -917,7 +917,7 @@ pcap_read_sita_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(sita_phdr, 1, SITA_HDR_LEN, fh);
bytes_read = file_read(sita_phdr, SITA_HDR_LEN, fh);
if (bytes_read != SITA_HDR_LEN) {
*err = file_error(fh);
if (*err == 0)
@ -1180,7 +1180,7 @@ pcap_read_bt_pseudoheader(FILE_T fh,
struct libpcap_bt_phdr phdr;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&phdr, 1,
bytes_read = file_read(&phdr,
sizeof (struct libpcap_bt_phdr), fh);
if (bytes_read != sizeof (struct libpcap_bt_phdr)) {
*err = file_error(fh);
@ -1200,7 +1200,7 @@ pcap_read_ppp_pseudoheader(FILE_T fh,
struct libpcap_ppp_phdr phdr;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&phdr, 1,
bytes_read = file_read(&phdr,
sizeof (struct libpcap_ppp_phdr), fh);
if (bytes_read != sizeof (struct libpcap_ppp_phdr)) {
*err = file_error(fh);
@ -1220,7 +1220,7 @@ pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr,
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_hdr, 1, sizeof(struct erf_phdr), fh);
bytes_read = file_read(erf_hdr, sizeof(struct erf_phdr), fh);
if (bytes_read != sizeof(struct erf_phdr)) {
*err = file_error(fh);
if (*err == 0)
@ -1268,7 +1268,7 @@ pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
if (pseudo_header->erf.phdr.type & 0x80){
do{
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_exhdr, 1, 8, fh);
bytes_read = file_read(erf_exhdr, 8, fh);
if (bytes_read != 8 ) {
*err = file_error(fh);
if (*err == 0)
@ -1308,7 +1308,7 @@ pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
case ERF_TYPE_COLOR_MC_HDLC_POS:
/* Extract the Multi Channel header to include it in the pseudo header part */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_subhdr, 1, 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) ) {
*err = file_error(fh);
if (*err == 0)
@ -1323,7 +1323,7 @@ pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
case ERF_TYPE_DSM_COLOR_ETH:
/* Extract the Ethernet additional header to include it in the pseudo header part */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_subhdr, 1, 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) ) {
*err = file_error(fh);
if (*err == 0)
@ -1347,7 +1347,7 @@ pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, i
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&i2c_hdr, 1, sizeof (i2c_hdr), fh);
bytes_read = file_read(&i2c_hdr, sizeof (i2c_hdr), fh);
if (bytes_read != sizeof (i2c_hdr)) {
*err = file_error(fh);
if (*err == 0)

View File

@ -343,7 +343,7 @@ pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh,
/* read option header */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(oh, 1, sizeof (*oh), fh);
bytes_read = file_read(oh, sizeof (*oh), fh);
if (bytes_read != sizeof (*oh)) {
pcapng_debug0("pcapng_read_option: failed to read option");
*err = file_error(fh);
@ -366,7 +366,7 @@ pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh,
/* read option content */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(content, 1, oh->option_length, fh);
bytes_read = file_read(content, oh->option_length, fh);
if (bytes_read != oh->option_length) {
pcapng_debug1("pcapng_read_if_descr_block: failed to read content of option %u", oh->option_code);
*err = file_error(fh);
@ -407,7 +407,7 @@ pcapng_read_section_header_block(FILE_T fh, gboolean first_block,
/* read block content */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&shb, 1, sizeof shb, fh);
bytes_read = file_read(&shb, sizeof shb, fh);
if (bytes_read != sizeof shb) {
*err = file_error(fh);
if (*err == 0) {
@ -585,7 +585,7 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
time_units_per_second = 1000000; /* default */
/* read block content */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&idb, 1, sizeof idb, fh);
bytes_read = file_read(&idb, sizeof idb, fh);
if (bytes_read != sizeof idb) {
pcapng_debug0("pcapng_read_if_descr_block: failed to read IDB");
*err = file_error(fh);
@ -787,7 +787,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
/* "(Enhanced) Packet Block" read fixed part */
errno = WTAP_ERR_CANT_READ;
if (enhanced) {
bytes_read = file_read(&epb, 1, sizeof epb, fh);
bytes_read = file_read(&epb, sizeof epb, fh);
if (bytes_read != sizeof epb) {
pcapng_debug0("pcapng_read_packet_block: failed to read packet data");
*err = file_error(fh);
@ -811,7 +811,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
wblock->data.packet.packet_len = epb.packet_len;
}
} else {
bytes_read = file_read(&pb, 1, sizeof pb, fh);
bytes_read = file_read(&pb, sizeof pb, fh);
if (bytes_read != sizeof pb) {
pcapng_debug0("pcapng_read_packet_block: failed to read packet data");
*err = file_error(fh);
@ -887,7 +887,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
/* "(Enhanced) Packet Block" read capture data */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read((guchar *) (wblock->frame_buffer), 1, 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)) {
*err = file_error(fh);
pcapng_debug1("pcapng_read_packet_block: couldn't read %u bytes of captured data",
@ -994,7 +994,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
/* "Simple Packet Block" read fixed part */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&spb, 1, sizeof spb, fh);
bytes_read = file_read(&spb, sizeof spb, fh);
if (bytes_read != sizeof spb) {
pcapng_debug0("pcapng_read_simple_packet_block: failed to read packet data");
*err = file_error(fh);
@ -1060,7 +1060,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
/* "Simple Packet Block" read capture data */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read((guchar *) (wblock->frame_buffer), 1, 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) {
*err = file_error(fh);
pcapng_debug1("pcapng_read_simple_packet_block: couldn't read %u bytes of captured data",
@ -1110,7 +1110,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
- sizeof(bh->block_total_length);
while (block_read < to_read) {
bytes_read = file_read(&nrb, 1, sizeof nrb, fh);
bytes_read = file_read(&nrb, sizeof nrb, fh);
if (bytes_read != sizeof nrb) {
pcapng_debug0("pcapng_read_name_resolution_block: failed to read record header");
*err = file_error(fh);
@ -1133,7 +1133,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
pcapng_debug0("pcapng_read_name_resolution_block: bad length or insufficient data for IPv4 record");
return 0;
}
bytes_read = file_read(nrb_rec, 1, nrb.record_len, fh);
bytes_read = file_read(nrb_rec, nrb.record_len, fh);
if (bytes_read != nrb.record_len) {
pcapng_debug0("pcapng_read_name_resolution_block: failed to read IPv4 record data");
*err = file_error(fh);
@ -1161,7 +1161,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
pcapng_debug0("pcapng_read_name_resolution_block: bad length or insufficient data for IPv6 record");
return 0;
}
bytes_read = file_read(nrb_rec, 1, nrb.record_len, fh);
bytes_read = file_read(nrb_rec, nrb.record_len, fh);
if (bytes_read != nrb.record_len) {
pcapng_debug0("pcapng_read_name_resolution_block: failed to read IPv6 record data");
*err = file_error(fh);
@ -1210,7 +1210,7 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
/* "Interface Statistics Block" read fixed part */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&isb, 1, sizeof isb, fh);
bytes_read = file_read(&isb, sizeof isb, fh);
if (bytes_read != sizeof isb) {
pcapng_debug0("pcapng_read_interface_statistics_block: failed to read packet data");
*err = file_error(fh);
@ -1344,7 +1344,7 @@ pcapng_read_block(FILE_T fh, gboolean first_block, pcapng_t *pn, wtapng_block_t
/* Try to read the (next) block header */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&bh, 1, sizeof bh, fh);
bytes_read = file_read(&bh, sizeof bh, fh);
if (bytes_read != sizeof bh) {
pcapng_debug0("pcapng_read_block: end of file or error");
*err = file_error(fh);
@ -1411,7 +1411,7 @@ pcapng_read_block(FILE_T fh, gboolean first_block, pcapng_t *pn, wtapng_block_t
/* sanity check: first and second block lengths must match */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&block_total_length, 1, sizeof block_total_length, fh);
bytes_read = file_read(&block_total_length, sizeof block_total_length, fh);
if (bytes_read != sizeof block_total_length) {
pcapng_debug0("pcapng_read_block: couldn't read second block length");
*err = file_error(fh);

View File

@ -109,7 +109,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a RADCOM file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(r_magic, 1, 8, wth->fh);
bytes_read = file_read(r_magic, 8, wth->fh);
if (bytes_read != 8) {
*err = file_error(wth->fh);
if (*err != 0)
@ -131,7 +131,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
* be located 32 bytes before the beginning of this string */
wth->data_offset = 8;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(t_magic, 1, 11, wth->fh);
bytes_read = file_read(t_magic, 11, wth->fh);
if (bytes_read != 11) {
*err = file_error(wth->fh);
if (*err != 0)
@ -144,7 +144,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
return -1;
wth->data_offset += 1;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(t_magic, 1, 11, wth->fh);
bytes_read = file_read(t_magic, 11, wth->fh);
if (bytes_read != 11) {
*err = file_error(wth->fh);
if (*err != 0)
@ -157,7 +157,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
/* Get capture start time */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&start_date, 1, sizeof(struct frame_date),
bytes_read = file_read(&start_date, sizeof(struct frame_date),
wth->fh);
if (bytes_read != sizeof(struct frame_date)) {
*err = file_error(wth->fh);
@ -188,7 +188,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
wth->data_offset += sizeof(struct frame_date);
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(search_encap, 1, 4, wth->fh);
bytes_read = file_read(search_encap, 4, wth->fh);
if (bytes_read != 4) {
goto read_error;
}
@ -198,7 +198,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
return -1;
wth->data_offset -= 3;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(search_encap, 1, 4, wth->fh);
bytes_read = file_read(search_encap, 4, wth->fh);
if (bytes_read != 4) {
goto read_error;
}
@ -208,7 +208,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
return -1;
wth->data_offset += 12;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(search_encap, 1, 4, wth->fh);
bytes_read = file_read(search_encap, 4, wth->fh);
if (bytes_read != 4) {
goto read_error;
}
@ -225,7 +225,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
return -1;
}
/*bytes_read = file_read(&next_date, 1, sizeof(struct frame_date), wth->fh);
/*bytes_read = file_read(&next_date, sizeof(struct frame_date), wth->fh);
errno = WTAP_ERR_CANT_READ;
if (bytes_read != sizeof(struct frame_date)) {
goto read_error;
@ -235,7 +235,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
if (file_seek(wth->fh, 1-sizeof(struct frame_date), SEEK_CUR, err) == -1)
return -1;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&next_date, 1, sizeof(struct frame_date),
bytes_read = file_read(&next_date, sizeof(struct frame_date),
wth->fh);
if (bytes_read != sizeof(struct frame_date)) {
goto read_error;
@ -359,7 +359,7 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
presence and size of an FCS to our caller?
That'd let us handle other file types as well. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&fcs, 1, sizeof fcs, wth->fh);
bytes_read = file_read(&fcs, sizeof fcs, wth->fh);
if (bytes_read != sizeof fcs) {
*err = file_error(wth->fh);
if (*err == 0)
@ -429,7 +429,7 @@ radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(hdr, 1, sizeof *hdr, fh);
bytes_read = file_read(hdr, sizeof *hdr, fh);
if (bytes_read != sizeof *hdr) {
*err = file_error(fh);
if (*err != 0)
@ -449,7 +449,7 @@ radcom_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(pd, 1, length, fh);
bytes_read = file_read(pd, length, fh);
if (bytes_read != length) {
*err = file_error(fh);

View File

@ -251,7 +251,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a "snoop" file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
*err = file_error(wth->fh);
if (*err != 0)
@ -266,7 +266,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
/* Read the rest of the header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh);
if (*err != 0)
@ -327,7 +327,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
/* Read first record header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&rec_hdr, 1, sizeof rec_hdr, wth->fh);
bytes_read = file_read(&rec_hdr, sizeof rec_hdr, wth->fh);
if (bytes_read != sizeof rec_hdr) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0)
@ -461,7 +461,7 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
/* Read record header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) {
*err = file_error(wth->fh);
if (*err == 0 && bytes_read != 0)
@ -607,7 +607,7 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
if ((unsigned)bytes_to_read > sizeof padbuf)
bytes_to_read = sizeof padbuf;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(padbuf, 1, bytes_to_read, wth->fh);
bytes_read = file_read(padbuf, bytes_to_read, wth->fh);
if (bytes_read != bytes_to_read) {
*err = file_error(wth->fh);
if (*err == 0)
@ -686,7 +686,7 @@ snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
guint16 vci;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&atm_phdr, 1, 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)) {
*err = file_error(fh);
if (*err == 0)
@ -779,7 +779,7 @@ snoop_read_shomiti_wireless_pseudoheader(FILE_T fh,
int rsize;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&whdr, 1, sizeof (shomiti_wireless_header), fh);
bytes_read = file_read(&whdr, sizeof (shomiti_wireless_header), fh);
if (bytes_read != sizeof (shomiti_wireless_header)) {
*err = file_error(fh);
if (*err == 0)
@ -830,7 +830,7 @@ snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(pd, 1, length, fh);
bytes_read = file_read(pd, length, fh);
if (bytes_read != length) {
*err = file_error(fh);

View File

@ -111,7 +111,7 @@ int tnef_open(wtap *wth, int *err, gchar **err_info _U_)
int bytes_read;
guint32 magic;
bytes_read = file_read(&magic, 1, sizeof magic, wth->fh);
bytes_read = file_read(&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
*err = file_error(wth->fh);
return (*err != 0) ? -1 : 0;

View File

@ -186,7 +186,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
/* Check the magic string at the start of the file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic)
{
*err = file_error(wth->fh);
@ -201,7 +201,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
/* Read the rest of the file header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&vfile_hdr, 1, sizeof vfile_hdr, wth->fh);
bytes_read = file_read(&vfile_hdr, sizeof vfile_hdr, wth->fh);
if (bytes_read != sizeof vfile_hdr)
{
*err = file_error(wth->fh);
@ -316,7 +316,7 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
/* Read the packet header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&vpkt_hdr, 1, phdr_size, wth->fh);
bytes_read = file_read(&vpkt_hdr, phdr_size, wth->fh);
if (bytes_read != phdr_size)
{
*err = file_error(wth->fh);
@ -336,7 +336,7 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
{
/* Read the atm packet header. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&vatm_hdr, 1, ahdr_size, wth->fh);
bytes_read = file_read(&vatm_hdr, ahdr_size, wth->fh);
if (bytes_read != ahdr_size)
{
*err = file_error(wth->fh);
@ -367,7 +367,7 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, packet_size);
*data_offset = wth->data_offset;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), 1,
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer),
packet_size, wth->fh);
if (bytes_read != (int) packet_size)
@ -503,7 +503,7 @@ static gboolean visual_seek_read (wtap *wth, gint64 seek_off,
/* Read the packet header to get the status flags. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&vpkt_hdr, 1, phdr_size, wth->random_fh);
bytes_read = file_read(&vpkt_hdr, phdr_size, wth->random_fh);
if (bytes_read != phdr_size) {
*err = file_error(wth->random_fh);
if (*err == 0)
@ -516,7 +516,7 @@ static gboolean visual_seek_read (wtap *wth, gint64 seek_off,
{
/* Read the atm packet header */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&vatm_hdr, 1, ahdr_size, wth->random_fh);
bytes_read = file_read(&vatm_hdr, ahdr_size, wth->random_fh);
if (bytes_read != ahdr_size)
{
*err = file_error(wth->fh);
@ -530,7 +530,7 @@ static gboolean visual_seek_read (wtap *wth, gint64 seek_off,
/* Read the packet data. */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(pd, sizeof(guint8), len, wth->random_fh);
bytes_read = file_read(pd, len, wth->random_fh);
if (bytes_read != len) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;

View File

@ -304,7 +304,7 @@ extern gint wtap_num_file_types;
G_STMT_START \
{ \
int _bytes_read; \
_bytes_read = file_read((target), 1, (num_bytes), (fh)); \
_bytes_read = file_read((target), (num_bytes), (fh)); \
if (_bytes_read != (int) (num_bytes)) { \
*(err) = file_error((fh)); \
return FALSE; \
@ -316,7 +316,7 @@ extern gint wtap_num_file_types;
G_STMT_START \
{ \
int _bytes_read; \
_bytes_read = file_read((target), 1, (num_bytes), (fh)); \
_bytes_read = file_read((target), (num_bytes), (fh)); \
if (_bytes_read != (int) (num_bytes)) { \
*(err) = file_error((fh)); \
if (*(err) == 0 && _bytes_read > 0) { \