Skip to content

Commit dd1ed08

Browse files
emastecperciva
authored andcommitted
openssh: Handle localtime_r() failure by return "UNKNOWN-TIME"
Apply openssh-portable commit 8b6c1f402feb by deraadt@openbsd.org Approved by: re (cperciva) Obtained from: openssh-portable PR: 288773 Reported by: wosch Sponsored by: The FreeBSD Foundation (cherry picked from commit ce03706) (cherry picked from commit 0a45aa9)
1 parent 0339b24 commit dd1ed08

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crypto/openssh/misc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,8 +2535,10 @@ format_absolute_time(uint64_t t, char *buf, size_t len)
25352535
time_t tt = t > SSH_TIME_T_MAX ? SSH_TIME_T_MAX : t;
25362536
struct tm tm;
25372537

2538-
localtime_r(&tt, &tm);
2539-
strftime(buf, len, "%Y-%m-%dT%H:%M:%S", &tm);
2538+
if (localtime_r(&tt, &tm) == NULL)
2539+
strlcpy(buf, "UNKNOWN-TIME", len);
2540+
else
2541+
strftime(buf, len, "%Y-%m-%dT%H:%M:%S", &tm);
25402542
}
25412543

25422544
/*

0 commit comments

Comments
 (0)