- tm = gmtime(&seconds);
- /* use ISO 8601 (RFC3339) format */
- strftime(time_buf, sizeof (time_buf), "%Y-%m-%dT%H:%M:%S", tm);
- ND_PRINT((ndo, " (%s)", time_buf));
+ seconds = (time_t)seconds_64bit;
+ if (seconds != seconds_64bit) {
+ /*
+ * It doesn't fit into a time_t, so we can't hand it
+ * to gmtime.
+ */
+ ND_PRINT(" (unrepresentable)");
+ } else {
+ tm = gmtime(&seconds);
+ if (tm == NULL) {
+ /*
+ * gmtime() can't handle it.
+ * (Yes, that might happen with some version of
+ * Microsoft's C library.)
+ */
+ ND_PRINT(" (unrepresentable)");
+ } else {
+ /* use ISO 8601 (RFC3339) format */
+ strftime(time_buf, sizeof (time_buf), "%Y-%m-%dT%H:%M:%S", tm);
+ ND_PRINT(" (%s)", time_buf);
+ }
+ }