From eff6f4441ac69dd20cff4f3aa2929ebf119dc066 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Thu, 2 Oct 2014 18:33:58 +0000 Subject: [PATCH] strptime: %s format fix. Almost never needed in real life because %s is tends to be only one format spec. 1) Return code of gmtime_r() is checked. 2) All flags are set. Submitted by: ache MFC after: 3 weeks --- lib/libc/stdtime/strptime.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index 1d8dad942298..8576bdb3750a 100644 --- a/lib/libc/stdtime/strptime.c +++ b/lib/libc/stdtime/strptime.c @@ -503,8 +503,11 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, } errno = sverrno; buf = cp; - gmtime_r(&t, tm); + if (gmtime_r(&t, tm) == NULL) + return (NULL); *GMTp = 1; + flags |= FLAG_YDAY | FLAG_WDAY | FLAG_MONTH | + FLAG_MDAY | FLAG_YEAR; } break;