reordercap: Handle IDBs in the middle of the file

We can read IDBs (and other non packet blocks) in the
middle of the file, so init the dump parameters after
reading all the frames. This will move the IDBs (and NRBs
and DSBs) to the start of the new output file (which might
have to happen if they're out of order.)

Note: Files with multiple Section Header Blocks probably still
aren't handled correctly, because the IDB number might need to be
rewritten (though we have some of that information after
commit 8ebde1309d)

Fix #19740
This commit is contained in:
John Thacker 2024-04-04 20:27:45 -04:00
parent 8b802bffd1
commit 0c637a2b5e
1 changed files with 3 additions and 3 deletions

View File

@ -276,9 +276,6 @@ main(int argc, char *argv[])
}
DEBUG_PRINT("file_type_subtype is %d\n", wtap_file_type_subtype(wth));
wtap_dump_params_init(&params, wth);
/* Allocate the array of frame pointers. */
frames = g_ptr_array_new();
@ -314,7 +311,10 @@ main(int argc, char *argv[])
printf("%u frames, %u out of order\n", frames->len, wrong_order_count);
wtap_dump_params_init(&params, wth);
/* Sort the frames */
/* XXX - Does this handle multiple SHBs correctly? */
if (wrong_order_count > 0) {
g_ptr_array_sort(frames, frames_compare);
}