Make peekclassic_read_packet_v56() more like the _v7 version.
authorGuy Harris <guy@alum.mit.edu>
Tue, 23 Sep 2014 01:37:50 +0000 (18:37 -0700)
committerGuy Harris <guy@alum.mit.edu>
Tue, 23 Sep 2014 02:10:35 +0000 (02:10 +0000)
We can't use wtap_file_read_expected_bytes() in the _v7 version, as that
version returns an int, not a Boolean; just expand
wtap_file_read_expected_bytes() in the _v56 version, to make it look
similar to the _v7 version.

Change-Id: Id907bac265c123ad5821591c1cf081b5747724d8
Reviewed-on: https://code.wireshark.org/review/4262
Reviewed-by: Guy Harris <guy@alum.mit.edu>
wiretap/peekclassic.c

index db6a97b2fdc58eb88d81225dae905b2584610c64..2167cbd64513428f63379f249f6ff18afff19fee 100644 (file)
@@ -532,6 +532,7 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
 {
        peekclassic_t *peekclassic = (peekclassic_t *)wth->priv;
        guint8 ep_pkt[PEEKCLASSIC_V56_PKT_SIZE];
+       int bytes_read;
        guint16 length;
        guint16 sliceLength;
 #if 0
@@ -549,8 +550,13 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
 #endif
        unsigned int i;
 
-       wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), fh, err,
-           err_info);
+       bytes_read = file_read(ep_pkt, sizeof(ep_pkt), fh);
+       if (bytes_read != (int) sizeof(ep_pkt)) {
+               *err = file_error(fh, err_info);
+               if (*err == 0 && bytes_read > 0)
+                       *err = WTAP_ERR_SHORT_READ;
+               return FALSE;
+       }
 
        /* Extract the fields from the packet */
        length = pntoh16(&ep_pkt[PEEKCLASSIC_V56_LENGTH_OFFSET]);