diff options
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/commview.c | 27 | ||||
-rw-r--r-- | wiretap/logcat_text.c | 43 | ||||
-rw-r--r-- | wiretap/network_instruments.c | 1 |
3 files changed, 52 insertions, 19 deletions
diff --git a/wiretap/commview.c b/wiretap/commview.c index f44dbe5578..e6dbd8101f 100644 --- a/wiretap/commview.c +++ b/wiretap/commview.c @@ -422,13 +422,26 @@ static gboolean commview_dump(wtap_dumper *wdh, cv_hdr.version = 0; tm = localtime(&phdr->ts.secs); - cv_hdr.year = tm->tm_year + 1900; - cv_hdr.month = tm->tm_mon + 1; - cv_hdr.day = tm->tm_mday; - cv_hdr.hours = tm->tm_hour; - cv_hdr.minutes = tm->tm_min; - cv_hdr.seconds = tm->tm_sec; - cv_hdr.usecs = GUINT32_TO_LE(phdr->ts.nsecs / 1000); + if (tm != NULL) { + cv_hdr.year = tm->tm_year + 1900; + cv_hdr.month = tm->tm_mon + 1; + cv_hdr.day = tm->tm_mday; + cv_hdr.hours = tm->tm_hour; + cv_hdr.minutes = tm->tm_min; + cv_hdr.seconds = tm->tm_sec; + cv_hdr.usecs = GUINT32_TO_LE(phdr->ts.nsecs / 1000); + } else { + /* + * Second before the Epoch. + */ + cv_hdr.year = 1969; + cv_hdr.month = 12; + cv_hdr.day = 31; + cv_hdr.hours = 23; + cv_hdr.minutes = 59; + cv_hdr.seconds = 59; + cv_hdr.usecs = 0; + } switch(phdr->pkt_encap) { diff --git a/wiretap/logcat_text.c b/wiretap/logcat_text.c index 551358170f..2f7e5bc294 100644 --- a/wiretap/logcat_text.c +++ b/wiretap/logcat_text.c @@ -104,6 +104,7 @@ static gchar *logcat_log(const struct dumper_t *dumper, guint32 seconds, { gchar time_buffer[15]; time_t datetime; + struct tm *tm; datetime = (time_t) seconds; @@ -123,20 +124,38 @@ static gchar *logcat_log(const struct dumper_t *dumper, guint32 seconds, return g_strdup_printf("%c(%5i:%5i) %s\n", priority, pid, tid, log); case WTAP_ENCAP_LOGCAT_TIME: - strftime(time_buffer, sizeof(time_buffer), "%m-%d %H:%M:%S", - gmtime(&datetime)); - return g_strdup_printf("%s.%03i %c/%-8s(%5i): %s\n", - time_buffer, milliseconds, priority, tag, pid, log); + tm = gmtime(&datetime); + if (tm != NULL) { + strftime(time_buffer, sizeof(time_buffer), "%m-%d %H:%M:%S", + tm); + return g_strdup_printf("%s.%03i %c/%-8s(%5i): %s\n", + time_buffer, milliseconds, priority, tag, pid, log); + } else { + return g_strdup_printf("Not representable %c/%-8s(%5i): %s\n", + priority, tag, pid, log); + } case WTAP_ENCAP_LOGCAT_THREADTIME: - strftime(time_buffer, sizeof(time_buffer), "%m-%d %H:%M:%S", - gmtime(&datetime)); - return g_strdup_printf("%s.%03i %5i %5i %c %-8s: %s\n", - time_buffer, milliseconds, pid, tid, priority, tag, log); + tm = gmtime(&datetime); + if (tm != NULL) { + strftime(time_buffer, sizeof(time_buffer), "%m-%d %H:%M:%S", + tm); + return g_strdup_printf("%s.%03i %5i %5i %c %-8s: %s\n", + time_buffer, milliseconds, pid, tid, priority, tag, log); + } else { + return g_strdup_printf("Not representable %5i %5i %c %-8s: %s\n", + pid, tid, priority, tag, log); + } case WTAP_ENCAP_LOGCAT_LONG: - strftime(time_buffer, sizeof(time_buffer), "%m-%d %H:%M:%S", - gmtime(&datetime)); - return g_strdup_printf("[ %s.%03i %5i:%5i %c/%-8s ]\n%s\n\n", - time_buffer, milliseconds, pid, tid, priority, tag, log); + tm = gmtime(&datetime); + if (tm != NULL) { + strftime(time_buffer, sizeof(time_buffer), "%m-%d %H:%M:%S", + tm); + return g_strdup_printf("[ %s.%03i %5i:%5i %c/%-8s ]\n%s\n\n", + time_buffer, milliseconds, pid, tid, priority, tag, log); + } else { + return g_strdup_printf("[ Not representable %5i:%5i %c/%-8s ]\n%s\n\n", + pid, tid, priority, tag, log); + } default: return NULL; } diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 19ff6fbba8..fb335f445c 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -614,6 +614,7 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, int *err) /* create the file comment TLV */ { time(&system_time); + /* We trusst the OS not to return a time before the Epoch */ current_time = localtime(&system_time); memset(&comment, 0x00, sizeof(comment)); g_snprintf(comment, 64, "This capture was saved from Wireshark on %s", asctime(current_time)); |