summaryrefslogtreecommitdiff
path: root/ui/text_import.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/text_import.c')
-rw-r--r--ui/text_import.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/ui/text_import.c b/ui/text_import.c
index 0536028a5b..812d34e64b 100644
--- a/ui/text_import.c
+++ b/ui/text_import.c
@@ -921,6 +921,7 @@ text_import(text_import_info_t *info)
{
yyscan_t scanner;
int ret;
+ struct tm *now_tm;
packet_buf = (guint8 *)g_malloc(sizeof(HDR_ETHERNET) + sizeof(HDR_IP) +
sizeof(HDR_SCTP) + sizeof(HDR_DATA_CHUNK) +
@@ -938,8 +939,17 @@ text_import(text_import_info_t *info)
packet_start = 0;
packet_preamble_len = 0;
ts_sec = time(0); /* initialize to current time */
- /* We trust the OS not to provide a time before the Epoch. */
- timecode_default = *localtime(&ts_sec);
+ now_tm = localtime(&ts_sec);
+ if (now_tm == NULL) {
+ /*
+ * This shouldn't happen - on UN*X, this should Just Work, and
+ * on Windows, it won't work if ts_sec is before the Epoch,
+ * but it's long after 1970, so....
+ */
+ fprintf(stderr, "localtime(right now) failed\n");
+ exit(-1);
+ }
+ timecode_default = *now_tm;
timecode_default.tm_isdst = -1; /* Unknown for now, depends on time given to the strptime() function */
ts_usec = 0;