diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2024-04-28 16:42:54 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2024-04-28 16:42:54 +0000 |
commit | cdc51f7b7a4cf42e605daf34492d4fc5f193d7ed (patch) | |
tree | 975c084c53612016a8f0f9a65dc9f3347588fd77 /libexec/ftpd | |
parent | 891358d20de03c388fb10d0148c4660261604dda (diff) |
gmtime(3) / locatime(3) can fail when timestamps are way off.
Add missing error checks to all calls under libexec/
Input & OK millert
Diffstat (limited to 'libexec/ftpd')
-rw-r--r-- | libexec/ftpd/ftpcmd.y | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y index e85d7ccb72f..e5d80528a65 100644 --- a/libexec/ftpd/ftpcmd.y +++ b/libexec/ftpd/ftpcmd.y @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpcmd.y,v 1.74 2023/03/08 04:43:05 guenther Exp $ */ +/* $OpenBSD: ftpcmd.y,v 1.75 2024/04/28 16:42:53 florian Exp $ */ /* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */ /* @@ -613,6 +613,11 @@ cmd } else { struct tm *t; t = gmtime(&stbuf.st_mtime); + if (t == NULL) { + /* invalid time, use epoch */ + stbuf.st_mtime = 0; + t = gmtime(&stbuf.st_mtime); + } reply(213, "%04d%02d%02d%02d%02d%02d", 1900 + t->tm_year, |