Don't map the interface ID for records that don't pertain to an interface.
authorGuy Harris <guy@alum.mit.edu>
Wed, 15 Jun 2016 19:15:54 +0000 (12:15 -0700)
committerGuy Harris <guy@alum.mit.edu>
Wed, 15 Jun 2016 19:16:19 +0000 (19:16 +0000)
And revert to the previous behavior of map_phdr_interface_id(); that
change broke the mergecap tests when it was merging pcap files into a
pcapng file.

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

index eced520ac725a3afb8f9c26f97fc056fc80e1322..6870e8cbeb7f06c120175b9198f02c257f26d5f6 100644 (file)
@@ -699,8 +699,6 @@ map_phdr_interface_id(struct wtap_pkthdr *phdr, const merge_in_file_t *in_file)
 
     if (phdr->presence_flags & WTAP_HAS_INTERFACE_ID) {
         current_interface_id = phdr->interface_id;
-    } else {
-        return TRUE;
     }
 
     if (current_interface_id >= in_file->idb_index_map->len) {
@@ -1009,9 +1007,17 @@ merge_files(int out_fd, const gchar* out_filename, const int file_type,
         }
 
         if (file_type == WTAP_FILE_TYPE_SUBTYPE_PCAPNG) {
-            if (!map_phdr_interface_id(phdr, in_file)) {
-                status = MERGE_ERR_BAD_PHDR_INTERFACE_ID;
-                break;
+            /*
+             * XXX - We should do this only for record types
+             * that pertain to a particular interface; for
+             * now, we hardcode that, but we need to figure
+             * out a more general way to handle this.
+             */
+            if (phdr->rec_type == REC_TYPE_PACKET) {
+                if (!map_phdr_interface_id(phdr, in_file)) {
+                    status = MERGE_ERR_BAD_PHDR_INTERFACE_ID;
+                    break;
+                }
             }
         }