summaryrefslogtreecommitdiff
path: root/dumpcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-10-21 19:18:15 -0700
committerGuy Harris <guy@alum.mit.edu>2016-10-22 02:27:32 +0000
commit10ca4c7527122efde0300205deaa6c0143f07219 (patch)
tree5352128043afff3b586c4a314ab2d240aec36f6a /dumpcap.c
parent49cf42c571f3f94632957371ccd99533e71764ff (diff)
downloadwireshark-10ca4c7527122efde0300205deaa6c0143f07219.tar.gz
More checks for localtime() and gmtime() returning NULL.
And some comments in the case where we're converting the result of time() - if your machine's idea of time predates January 1, 1970, 00:00:00 UTC, it'll crash on Windows, but that's not a case where a *file* can cause the problem due either to a bad file time stamp or bad time stamps in the file. Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498 Reviewed-on: https://code.wireshark.org/review/18369 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'dumpcap.c')
-rw-r--r--dumpcap.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/dumpcap.c b/dumpcap.c
index be1910fd24..be96c173a7 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -4509,10 +4509,6 @@ console_log_handler(const char *log_domain, GLogLevelFlags log_level,
#endif
}
- /* create a "timestamp" */
- time(&curr);
- today = localtime(&curr);
-
switch(log_level & G_LOG_LEVEL_MASK) {
case G_LOG_LEVEL_ERROR:
level = "Err ";
@@ -4543,11 +4539,20 @@ console_log_handler(const char *log_domain, GLogLevelFlags log_level,
/* normal user messages without additional infos */
msg = g_strdup_printf("%s\n", message);
} else {
+ /* create a "timestamp" */
+ time(&curr);
+ today = localtime(&curr);
+
/* info/debug messages with additional infos */
- msg = g_strdup_printf("%02u:%02u:%02u %8s %s %s\n",
- today->tm_hour, today->tm_min, today->tm_sec,
- log_domain != NULL ? log_domain : "",
- level, message);
+ if (today != NULL)
+ msg = g_strdup_printf("%02u:%02u:%02u %8s %s %s\n",
+ today->tm_hour, today->tm_min, today->tm_sec,
+ log_domain != NULL ? log_domain : "",
+ level, message);
+ else
+ msg = g_strdup_printf("Time not representable %8s %s %s\n",
+ log_domain != NULL ? log_domain : "",
+ level, message);
}
/* DEBUG & INFO msgs (if we're debugging today) */