From cdbe7846a912f2650f947b9b11644306f2c31de3 Mon Sep 17 00:00:00 2001 From: ache Date: Tue, 7 Oct 2014 06:34:05 +0000 Subject: 1) Fix the case we have less arguments for format string than we expected. 2) Return error on unsupported format specs. (both according to POSIX) PR: 93197 --- lib/libc/stdtime/strptime.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index e942e04..2be6358 100644 --- a/lib/libc/stdtime/strptime.c +++ b/lib/libc/stdtime/strptime.c @@ -103,9 +103,6 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, ptr = fmt; while (*ptr != 0) { - if (*buf == 0) - break; - c = *ptr++; if (c != '%') { @@ -123,7 +120,6 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, label: c = *ptr++; switch (c) { - case 0: case '%': if (*buf++ != '%') return (NULL); @@ -600,6 +596,9 @@ label: while (isspace_l((unsigned char)*buf, locale)) buf++; break; + + default: + return (NULL); } } -- cgit v1.1