Check for localtime() failing.
It "shouldn't happen", but at least this squelches a Coverity complaint, CID 1394503. Change-Id: I40af10d47c1d1b026f6b40ef68b139e6bf246109 Reviewed-on: https://code.wireshark.org/review/20774 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
1bea950b7a
commit
630b5a8165
14
text2pcap.c
14
text2pcap.c
|
@ -1469,6 +1469,7 @@ parse_options (int argc, char *argv[])
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{0, 0, 0, 0 }
|
{0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
struct tm *now_tm;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
arg_list_utf_16to8(argc, argv);
|
arg_list_utf_16to8(argc, argv);
|
||||||
|
@ -1833,8 +1834,17 @@ parse_options (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
ts_sec = time(0); /* initialize to current time */
|
ts_sec = time(0); /* initialize to current time */
|
||||||
/* We trust the OS to return a time after the Epoch. */
|
now_tm = localtime(&ts_sec);
|
||||||
timecode_default = *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");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
timecode_default = *now_tm;
|
||||||
timecode_default.tm_isdst = -1; /* Unknown for now, depends on time given to the strptime() function */
|
timecode_default.tm_isdst = -1; /* Unknown for now, depends on time given to the strptime() function */
|
||||||
|
|
||||||
/* Display summary of our state */
|
/* Display summary of our state */
|
||||||
|
|
Loading…
Reference in New Issue