summaryrefslogtreecommitdiff
path: root/editcap.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2015-07-20 11:09:06 -0400
committerAnders Broman <a.broman58@gmail.com>2015-08-18 05:52:45 +0000
commite25562baddd7a675510daea9bb6a6e4ab36b2d68 (patch)
tree2338173d5f211716b8004c915ee92713d197c1b1 /editcap.c
parent4048ca0a27b7ed693b91103ed6912a4a1abfa3db (diff)
downloadwireshark-e25562baddd7a675510daea9bb6a6e4ab36b2d68.tar.gz
Pcapng: clean up Section Header Block handling
Change-Id: I8516d0c561ed0b63e49a3594027c9c15bb789258 Reviewed-on: https://code.wireshark.org/review/9726 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/editcap.c b/editcap.c
index 5457100d8e..a57d012cb9 100644
--- a/editcap.c
+++ b/editcap.c
@@ -1285,7 +1285,7 @@ DIAG_ON(cast-qual)
wtap_file_type_subtype_string(wtap_file_type_subtype(wth)));
}
- shb_hdr = wtap_file_get_shb_info(wth);
+ shb_hdr = wtap_file_get_shb_for_new_file(wth);
idb_inf = wtap_file_get_idb_info(wth);
nrb_hdr = wtap_file_get_nrb_for_new_file(wth);
@@ -1320,7 +1320,7 @@ DIAG_ON(cast-qual)
if (read_count == 1) {
if (split_packet_count > 0 || secs_per_block > 0) {
if (!fileset_extract_prefix_suffix(argv[optind+1], &fprefix, &fsuffix))
- exit(2);
+ goto error_on_exit;
filename = fileset_get_filename_by_pattern(block_cnt++, phdr, fprefix, fsuffix);
} else {
@@ -1340,7 +1340,7 @@ DIAG_ON(cast-qual)
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
- exit(2);
+ goto error_on_exit;
}
} /* first packet only handling */
@@ -1365,7 +1365,7 @@ DIAG_ON(cast-qual)
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));
- exit(2);
+ goto error_on_exit;
}
block_start.secs = block_start.secs + secs_per_block; /* reset for next interval */
g_free(filename);
@@ -1382,7 +1382,7 @@ DIAG_ON(cast-qual)
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
- exit(2);
+ goto error_on_exit;
}
}
}
@@ -1394,7 +1394,7 @@ DIAG_ON(cast-qual)
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));
- exit(2);
+ goto error_on_exit;
}
g_free(filename);
@@ -1410,7 +1410,7 @@ DIAG_ON(cast-qual)
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
- exit(2);
+ goto error_on_exit;
}
}
} /* split packet handling */
@@ -1747,7 +1747,7 @@ DIAG_ON(cast-qual)
filename, wtap_strerror(err));
break;
}
- exit(2);
+ goto error_on_exit;
}
written_count++;
}
@@ -1781,7 +1781,7 @@ DIAG_ON(cast-qual)
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
- exit(2);
+ goto error_on_exit;
}
}
@@ -1791,9 +1791,9 @@ DIAG_ON(cast-qual)
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n", filename,
wtap_strerror(err));
- exit(2);
+ goto error_on_exit;
}
- g_free(shb_hdr);
+ wtap_free_shb(shb_hdr);
shb_hdr = NULL;
wtap_free_nrb(nrb_hdr);
nrb_hdr = NULL;
@@ -1817,6 +1817,12 @@ DIAG_ON(cast-qual)
}
return 0;
+
+error_on_exit:
+ wtap_free_shb(shb_hdr);
+ wtap_free_nrb(nrb_hdr);
+ g_free(idb_inf);
+ exit(2);
}
/* Skip meta-information read from file to return offset of real