Make sure the packet length isn't > WTAP_MAX_PACKET_SIZE.
[metze/wireshark/wip.git] / wiretap / peekclassic.c
index bb147f1a7ae3d31215c23ffb70c2f26a69bb8465..5cbefbb3944f819e5c7f4378a6d527de9af04208 100644 (file)
@@ -434,6 +434,11 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
        if (0 == sliceLength) {
                sliceLength = length;
        }
+       /*
+        * The maximum value of sliceLength and length are 65535, which
+        * are less than WTAP_MAX_PACKET_SIZE will ever be, so we don't
+        * need to check them.
+        */
 
        /* fill in packet header values */
        phdr->rec_type = REC_TYPE_PACKET;
@@ -448,14 +453,11 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
        switch (wth->file_encap) {
 
        case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
+               memset(&phdr->pseudo_header.ieee_802_11, 0, sizeof(phdr->pseudo_header.ieee_802_11));
                phdr->pseudo_header.ieee_802_11.fcs_len = 0;            /* no FCS */
                phdr->pseudo_header.ieee_802_11.decrypted = FALSE;
                phdr->pseudo_header.ieee_802_11.datapad = FALSE;
                phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN;
-               phdr->pseudo_header.ieee_802_11.presence_flags =
-                   PHDR_802_11_HAS_DATA_RATE |
-                   PHDR_802_11_HAS_CHANNEL |
-                   PHDR_802_11_HAS_SIGNAL_PERCENT;
 
                /*
                 * Now process the radio information pseudo-header.
@@ -490,8 +492,13 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
                if (!wtap_read_bytes(fh, radio_info, RADIO_INFO_SIZE, err, err_info))
                        return -1;
 
+               phdr->pseudo_header.ieee_802_11.has_data_rate = TRUE;
                phdr->pseudo_header.ieee_802_11.data_rate = radio_info[0];
+
+               phdr->pseudo_header.ieee_802_11.has_channel = TRUE;
                phdr->pseudo_header.ieee_802_11.channel = radio_info[1];
+
+               phdr->pseudo_header.ieee_802_11.has_signal_percent = TRUE;
                phdr->pseudo_header.ieee_802_11.signal_percent = radio_info[2];
 
                /*
@@ -611,6 +618,11 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
        if (0 == sliceLength) {
                sliceLength = length;
        }
+       /*
+        * The maximum value of sliceLength and length are 65535, which
+        * are less than WTAP_MAX_PACKET_SIZE will ever be, so we don't
+        * need to check them.
+        */
 
        /* fill in packet header values */
        phdr->rec_type = REC_TYPE_PACKET;