diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-07-15 19:14:03 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-07-15 19:14:03 +0000 |
commit | b7255e108a8e22f9fc458ad644e43e9475f51fd0 (patch) | |
tree | 868384d9df93246ae15a0650cf5fdcc47b65cb23 /wiretap/netmon.c | |
parent | e574c8de6d5cd2684265ce041539614c8872f781 (diff) | |
download | wireshark-b7255e108a8e22f9fc458ad644e43e9475f51fd0.tar.gz wireshark-b7255e108a8e22f9fc458ad644e43e9475f51fd0.tar.bz2 wireshark-b7255e108a8e22f9fc458ad644e43e9475f51fd0.zip |
Fixes, from Scott Renfro, for some calls to "localtime()" that didn't
check whether the call succeeded (it doesn't always do so on Windows,
for example).
svn path=/trunk/; revision=3722
Diffstat (limited to 'wiretap/netmon.c')
-rw-r--r-- | wiretap/netmon.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/wiretap/netmon.c b/wiretap/netmon.c index a0b489a71f..d90f601155 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -1,6 +1,6 @@ /* netmon.c * - * $Id: netmon.c,v 1.38 2001/07/13 00:55:58 guy Exp $ + * $Id: netmon.c,v 1.39 2001/07/15 19:14:03 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org> @@ -635,14 +635,24 @@ static gboolean netmon_dump_close(wtap_dumper *wdh, int *err) file_hdr.network = htoles(wtap_encap[wdh->encap]); tm = localtime(&netmon->first_record_time.tv_sec); - file_hdr.ts_year = htoles(1900 + tm->tm_year); - file_hdr.ts_month = htoles(tm->tm_mon + 1); - file_hdr.ts_dow = htoles(tm->tm_wday); - file_hdr.ts_day = htoles(tm->tm_mday); - file_hdr.ts_hour = htoles(tm->tm_hour); - file_hdr.ts_min = htoles(tm->tm_min); - file_hdr.ts_sec = htoles(tm->tm_sec); - file_hdr.ts_msec = htoles(netmon->first_record_time.tv_usec/1000); + if (tm != NULL) { + file_hdr.ts_year = htoles(1900 + tm->tm_year); + file_hdr.ts_month = htoles(tm->tm_mon + 1); + file_hdr.ts_dow = htoles(tm->tm_wday); + file_hdr.ts_day = htoles(tm->tm_mday); + file_hdr.ts_hour = htoles(tm->tm_hour); + file_hdr.ts_min = htoles(tm->tm_min); + file_hdr.ts_sec = htoles(tm->tm_sec); + } else { + file_hdr.ts_year = htoles(1900 + 0); + file_hdr.ts_month = htoles(0 + 1); + file_hdr.ts_dow = htoles(0); + file_hdr.ts_day = htoles(0); + file_hdr.ts_hour = htoles(0); + file_hdr.ts_min = htoles(0); + file_hdr.ts_sec = htoles(0); + } + file_hdr.ts_msec = htoles(netmon->first_record_time.tv_usec/1000); /* XXX - what about rounding? */ file_hdr.frametableoffset = htolel(netmon->frame_table_offset); file_hdr.frametablelength = |