When doing a seek-and-read, don't check the packet size, as we don't
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 2 Jun 2009 19:06:05 +0000 (19:06 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 2 Jun 2009 19:06:05 +0000 (19:06 +0000)
have it (we have the size with the pseudo-header length already
removed); we've already read the packet, and thus have already checked
it.  Fixes bug 3501.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28607 f5534014-38df-0310-8fa8-9805f1628bb7

wiretap/libpcap.c
wiretap/pcap-common.c
wiretap/pcap-common.h

index 9668fd104fde83d7118697fad27adb97f4a3aa90..beee98f4fd156ce99ea7b870688b8cc79e90e5c0 100644 (file)
@@ -637,7 +637,7 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
        *data_offset = wth->data_offset;
 
        phdr_len = pcap_process_pseudo_header(wth, wth->fh, packet_size,
-           &wth->phdr, &wth->pseudo_header, err, err_info);
+           TRUE, &wth->phdr, &wth->pseudo_header, err, err_info);
        if (phdr_len < 0)
                return FALSE;   /* error */
 
@@ -705,7 +705,7 @@ libpcap_seek_read(wtap *wth, gint64 seek_off,
                return FALSE;
 
        phdr_len = pcap_process_pseudo_header(wth, wth->random_fh, length,
-           NULL, pseudo_header, err, err_info);
+           FALSE, NULL, pseudo_header, err, err_info);
        if (phdr_len < 0)
                return FALSE;   /* error */
 
index 03cb2780c38f07f8f3b45f8dfdd034fc43928ad7..e096fc9f36ee67e733dd309fdf5d74a0b320052f 100644 (file)
@@ -1116,8 +1116,8 @@ pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, i
 
 int
 pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
-    struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header,
-    int *err, gchar **err_info)
+    gboolean check_packet_size, struct wtap_pkthdr *phdr,
+    union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
 {
        int phdr_len = 0;
        guint size;
@@ -1129,7 +1129,7 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
                        /*
                         * Nokia IPSO ATM.
                         */
-                       if (packet_size < NOKIAATM_LEN) {
+                       if (check_packet_size && packet_size < NOKIAATM_LEN) {
                                /*
                                 * Uh-oh, the packet isn't big enough to even
                                 * have a pseudo-header.
@@ -1148,7 +1148,7 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
                        /*
                         * SunATM.
                         */
-                       if (packet_size < SUNATM_LEN) {
+                       if (check_packet_size && packet_size < SUNATM_LEN) {
                                /*
                                 * Uh-oh, the packet isn't big enough to even
                                 * have a pseudo-header.
@@ -1189,7 +1189,7 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
                break;
 
        case WTAP_ENCAP_IRDA:
-               if (packet_size < IRDA_SLL_LEN) {
+               if (check_packet_size && packet_size < IRDA_SLL_LEN) {
                        /*
                         * Uh-oh, the packet isn't big enough to even
                         * have a pseudo-header.
@@ -1207,7 +1207,7 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
                break;
 
        case WTAP_ENCAP_MTP2_WITH_PHDR:
-               if (packet_size < MTP2_HDR_LEN) {
+               if (check_packet_size && packet_size < MTP2_HDR_LEN) {
                        /*
                         * Uh-oh, the packet isn't big enough to even
                         * have a pseudo-header.
@@ -1225,7 +1225,7 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
                break;
 
        case WTAP_ENCAP_LINUX_LAPD:
-               if (packet_size < LAPD_SLL_LEN) {
+               if (check_packet_size && packet_size < LAPD_SLL_LEN) {
                        /*
                         * Uh-oh, the packet isn't big enough to even
                         * have a pseudo-header.
@@ -1243,7 +1243,7 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
                break;
 
        case WTAP_ENCAP_SITA:
-               if (packet_size < SITA_HDR_LEN) {
+               if (check_packet_size && packet_size < SITA_HDR_LEN) {
                        /*
                         * Uh-oh, the packet isn't big enough to even
                         * have a pseudo-header.
@@ -1262,7 +1262,8 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
 
        case WTAP_ENCAP_USB_LINUX:
        case WTAP_ENCAP_USB_LINUX_MMAPPED:
-               if (packet_size < sizeof (struct linux_usb_phdr)) {
+               if (check_packet_size &&
+                   packet_size < sizeof (struct linux_usb_phdr)) {
                        /*
                         * Uh-oh, the packet isn't big enough to even
                         * have a pseudo-header.
@@ -1285,7 +1286,8 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
                break;
 
        case WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR:
-               if (packet_size < sizeof (struct libpcap_bt_phdr)) {
+               if (check_packet_size &&
+                   packet_size < sizeof (struct libpcap_bt_phdr)) {
                        /*
                         * Uh-oh, the packet isn't big enough to even
                         * have a pseudo-header.
@@ -1303,7 +1305,8 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
                break;
 
        case WTAP_ENCAP_ERF:
-               if (packet_size < sizeof(struct erf_phdr) ) {
+               if (check_packet_size &&
+                   packet_size < sizeof(struct erf_phdr) ) {
                        /*
                         * Uh-oh, the packet isn't big enough to even
                         * have a pseudo-header.
@@ -1336,7 +1339,8 @@ pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
                break;
 
        case WTAP_ENCAP_I2C:
-               if (packet_size < sizeof (struct i2c_file_hdr)) {
+               if (check_packet_size &&
+                   packet_size < sizeof (struct i2c_file_hdr)) {
                        /*
                         * Uh-oh, the packet isn't big enough to even
                         * have a pseudo-header.
index a058779454c523194ebcf8cb0ea2b040acce25b9..a0a7da91d9cb6ce6a08f9ec64d2c3184705a8317 100644 (file)
@@ -27,8 +27,8 @@
 extern int wtap_wtap_encap_to_pcap_encap(int encap);
 
 extern int pcap_process_pseudo_header(wtap *wth, FILE_T fh, guint packet_size,
-    struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header,
-    int *err, gchar **err_info);
+    gboolean check_packet_size, struct wtap_pkthdr *phdr,
+    union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
 
 extern int pcap_get_phdr_size(int encap,
     const union wtap_pseudo_header *pseudo_header);