aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2020-02-19 17:15:05 -0800
committerAnders Broman <a.broman58@gmail.com>2020-02-24 07:43:22 +0000
commite54bcb0100a75fc687cb25beda41a902aa344d27 (patch)
tree81a85aa9f7ba911668c68a72de88cd9109de9b86 /editcap.c
parent0875845e90d7ac9e7e905be09668d7a38410229a (diff)
editcap: Remove an arbitrary time boundary.
As pointed out by @debookee in https://twitter.com/debookee/status/1229711779648933888 if you pass a start time (-A) and no stop time (-B) to editcap, it will set the stop time to December 31, 2035. Adjust our logic to work without a stop time instead. Change-Id: Ic724ce8ee6d8c346be1d4caf2899d3e10e68fa94 Reviewed-on: https://code.wireshark.org/review/36138 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/editcap.c b/editcap.c
index 2f6e6f7566..b477aa8b99 100644
--- a/editcap.c
+++ b/editcap.c
@@ -1441,19 +1441,6 @@ main(int argc, char *argv[])
srand(seed);
}
- if (check_startstop && !stoptime) {
- struct tm stoptm;
-
- /* XXX: will work until 2035 */
- memset(&stoptm,0,sizeof(struct tm));
- stoptm.tm_year = 135;
- stoptm.tm_mday = 31;
- stoptm.tm_mon = 11;
- stoptm.tm_isdst = -1;
-
- stoptime = mktime(&stoptm);
- }
-
if (starttime > stoptime) {
fprintf(stderr, "editcap: start time is after the stop time\n");
ret = INVALID_OPTION;
@@ -1692,14 +1679,20 @@ main(int argc, char *argv[])
} /* split packet handling */
if (check_startstop) {
+ ts_okay = FALSE;
/*
* Is the packet in the selected timeframe?
* If the packet has no time stamp, the answer is "no".
*/
- if (rec->presence_flags & WTAP_HAS_TS)
- ts_okay = (rec->ts.secs >= starttime) && (rec->ts.secs < stoptime);
- else
- ts_okay = FALSE;
+ if (rec->presence_flags & WTAP_HAS_TS) {
+ if (starttime && stoptime) {
+ ts_okay = (rec->ts.secs >= starttime) && (rec->ts.secs < stoptime);
+ } else if (starttime) {
+ ts_okay = rec->ts.secs >= starttime;
+ } else if (stoptime) {
+ ts_okay = rec->ts.secs < stoptime;
+ }
+ }
} else {
/*
* No selected timeframe, so all packets are "in the