forked from osmocom/wireshark
cli: Process IDBs after the final packet record
Process IDBs that are read after the final packet record returned by wtap_read() in tshark, editcap, and mergecap. Ping #18449
This commit is contained in:
parent
3aa44ba6aa
commit
8cddc32d35
22
editcap.c
22
editcap.c
|
@ -1122,7 +1122,7 @@ process_new_idbs(wtap *wth, wtap_dumper *pdh, GArray *idbs_seen,
|
|||
* That mean that the abstract interface provided by libwiretap
|
||||
* involves WTAP_BLOCK_IF_ID_AND_INFO blocks.
|
||||
*/
|
||||
if (wtap_file_type_subtype_supports_block(wtap_dump_file_type_subtype(pdh),
|
||||
if (pdh != NULL && wtap_file_type_subtype_supports_block(wtap_dump_file_type_subtype(pdh),
|
||||
WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
|
||||
wtap_block_t if_data_copy;
|
||||
|
||||
|
@ -1849,11 +1849,9 @@ main(int argc, char *argv[])
|
|||
while (wtap_read(wth, &read_rec, &read_buf, &read_err, &read_err_info, &data_offset)) {
|
||||
/*
|
||||
* XXX - what about non-packet records in the file after this?
|
||||
* We can *probably* ignore IDBs after this point, as they
|
||||
* presumably indicate that we weren't capturing on that
|
||||
* interface at this point, but what about, for example, ISBs?
|
||||
* (NRBs and DSBs are now written when wtap_dump_close() calls
|
||||
* pcapng_dump_finish().)
|
||||
* NRBs, DSBs, and ISBs are now written when wtap_dump_close() calls
|
||||
* pcapng_dump_finish(), and we handle IDBs below, but what about
|
||||
* custom blocks?
|
||||
*/
|
||||
if (max_packet_number <= read_count)
|
||||
break;
|
||||
|
@ -2389,6 +2387,18 @@ main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Process whatever IDBs we haven't seen yet.
|
||||
*/
|
||||
if (!process_new_idbs(wth, pdh, idbs_seen, &write_err, &write_err_info)) {
|
||||
cfile_write_failure_message(argv[ws_optind], filename,
|
||||
write_err, write_err_info,
|
||||
read_count,
|
||||
out_file_type_subtype);
|
||||
ret = DUMP_ERROR;
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
if (!wtap_dump_close(pdh, NULL, &write_err, &write_err_info)) {
|
||||
cfile_close_failure_message(filename, write_err, write_err_info);
|
||||
ret = WRITE_ERROR;
|
||||
|
|
16
tshark.c
16
tshark.c
|
@ -3583,9 +3583,19 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
|
|||
}
|
||||
wtap_rec_reset(&rec);
|
||||
}
|
||||
if (*err != 0 && status == PASS_SUCCEEDED) {
|
||||
/* Error reading from the input file. */
|
||||
status = PASS_READ_ERROR;
|
||||
if (status == PASS_SUCCEEDED) {
|
||||
if (*err != 0) {
|
||||
/* Error reading from the input file. */
|
||||
status = PASS_READ_ERROR;
|
||||
} else {
|
||||
/*
|
||||
* Process whatever IDBs we haven't seen yet.
|
||||
*/
|
||||
if (!process_new_idbs(cf->provider.wth, pdh, err, err_info)) {
|
||||
*err_framenum = framenum;
|
||||
status = PASS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (edt)
|
||||
|
|
|
@ -1046,7 +1046,13 @@ merge_process_packets(wtap_dumper *pdh, const int file_type,
|
|||
cb->callback_func(MERGE_EVENT_DONE, count, in_files, in_file_count, cb->data);
|
||||
|
||||
if (status == MERGE_OK || status == MERGE_USER_ABORTED) {
|
||||
/* Check for any NRBs or DSBs read after the last packet records. */
|
||||
/* Check for IDBs, NRBs, or DSBs read after the last packet records. */
|
||||
if (wtap_file_type_subtype_supports_block(file_type,
|
||||
WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
|
||||
if (!process_new_idbs(pdh, in_files, in_file_count, mode, idb_inf, err, err_info)) {
|
||||
status = MERGE_ERR_CANT_WRITE_OUTFILE;
|
||||
}
|
||||
}
|
||||
if (nrb_combined) {
|
||||
for (guint j = 0; j < in_file_count; j++) {
|
||||
in_file = &in_files[j];
|
||||
|
@ -1073,6 +1079,8 @@ merge_process_packets(wtap_dumper *pdh, const int file_type,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status == MERGE_OK || status == MERGE_USER_ABORTED) {
|
||||
if (!wtap_dump_close(pdh, NULL, err, err_info))
|
||||
status = MERGE_ERR_CANT_CLOSE_OUTFILE;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue