summaryrefslogtreecommitdiff
path: root/lib/libc/stdtime
diff options
context:
space:
mode:
authorSheldon Hearn <sheldonh@FreeBSD.org>1999-11-10 14:40:59 +0000
committerSheldon Hearn <sheldonh@FreeBSD.org>1999-11-10 14:40:59 +0000
commit33dbb0a6309129182f85ad9f82c7e7e5a9d2aa6c (patch)
treefcdb6296c732d2c2215556388cf16e64a485972c /lib/libc/stdtime
parent646e0924a1292fa46464e08990d513e8d76db7db (diff)
Notes
Diffstat (limited to 'lib/libc/stdtime')
-rw-r--r--lib/libc/stdtime/strptime.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c
index 7f2de92047e8..f9a385514e62 100644
--- a/lib/libc/stdtime/strptime.c
+++ b/lib/libc/stdtime/strptime.c
@@ -171,10 +171,10 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
i *= 10;
i += *buf - '0';
}
- if (i > 365)
+ if (i < 1 || i > 366)
return 0;
- tm->tm_yday = i;
+ tm->tm_yday = i - 1;
break;
case 'M':
@@ -189,13 +189,16 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
i *= 10;
i += *buf - '0';
}
- if (i > 59)
- return 0;
- if (c == 'M')
+ if (c == 'M') {
+ if (i > 59)
+ return 0;
tm->tm_min = i;
- else
+ } else {
+ if (i > 60)
+ return 0;
tm->tm_sec = i;
+ }
if (*buf != 0 && isspace((unsigned char)*buf))
while (*ptr != 0 && !isspace((unsigned char)*ptr))
@@ -271,6 +274,47 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)
buf += len;
break;
+ case 'U':
+ case 'W':
+ /*
+ * XXX This is bogus, as we can not assume any valid
+ * information present in the tm structure at this
+ * point to calculate a real value, so just check the
+ * range for now.
+ */
+ if (!isdigit((unsigned char)*buf))
+ return 0;
+
+ for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
+ i *= 10;
+ i += *buf - '0';
+ }
+ if (i > 53)
+ return 0;
+
+ if (*buf != 0 && isspace((unsigned char)*buf))
+ while (*ptr != 0 && !isspace((unsigned char)*ptr))
+ ptr++;
+ break;
+
+ case 'w':
+ if (!isdigit((unsigned char)*buf))
+ return 0;
+
+ for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
+ i *= 10;
+ i += *buf - '0';
+ }
+ if (i > 6)
+ return 0;
+
+ tm->tm_wday = i;
+
+ if (*buf != 0 && isspace((unsigned char)*buf))
+ while (*ptr != 0 && !isspace((unsigned char)*ptr))
+ ptr++;
+ break;
+
case 'd':
case 'e':
if (!isdigit((unsigned char)*buf))