You have to set tm_isdst before calling mktime().

You either need to tell mktime() that 1) DST/Summer Time is in effect,
2) DST/Summer Time isn't in effect, or 3) we don't know whether
DST/Summer Time is in effect, you figure it out.

We set tm_isdst to -1, to choose option 3), which is what we want.

Fixes Coverity CID 1435496.

Change-Id: I0f22ef1201ee8abefb3fa75aa3432b021fb13cfd
Reviewed-on: https://code.wireshark.org/review/27408
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-05-08 20:47:58 -07:00
parent 270f0554d8
commit 4513c66b1a
1 changed files with 2 additions and 0 deletions

View File

@ -1578,6 +1578,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo,
date.tm_min, date.tm_sec, ms, direction_character);
date.tm_mon -= 1;
date.tm_year -= 1900;
date.tm_isdst = -1;
ts = mktime(&date);
new_hex_data = data + 29;
@ -2128,6 +2129,7 @@ static int capture_android_logcat_text(char *interface, char *fifo,
if (6 == sscanf(packet + exported_pdu_headers_size, "%d-%d %d:%d:%d.%d", &date->tm_mon, &date->tm_mday, &date->tm_hour,
&date->tm_min, &date->tm_sec, &ms)) {
date->tm_mon -= 1;
date->tm_isdst = -1;
seconds = mktime(date);
secs = (time_t) seconds;
nsecs = (int) (ms * 1e6);