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
This commit is contained in:
Andrey A. Chernov 2014-10-07 06:34:05 +00:00
parent e15d3f3c09
commit 097c578c1e

View File

@ -103,9 +103,6 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp,
ptr = fmt; ptr = fmt;
while (*ptr != 0) { while (*ptr != 0) {
if (*buf == 0)
break;
c = *ptr++; c = *ptr++;
if (c != '%') { if (c != '%') {
@ -123,7 +120,6 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp,
label: label:
c = *ptr++; c = *ptr++;
switch (c) { switch (c) {
case 0:
case '%': case '%':
if (*buf++ != '%') if (*buf++ != '%')
return (NULL); return (NULL);
@ -600,6 +596,9 @@ label:
while (isspace_l((unsigned char)*buf, locale)) while (isspace_l((unsigned char)*buf, locale))
buf++; buf++;
break; break;
default:
return (NULL);
} }
} }