diff options
author | joe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845> | 2018-10-12 09:46:51 +0000 |
---|---|---|
committer | joe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845> | 2018-10-12 09:46:51 +0000 |
commit | dde3eb8170932338a806f6a344083c8469204c62 (patch) | |
tree | 243aff2a1ff9583fb472bcb0490a69625e2532cd /src/ne_dates.c | |
parent | d7134e39974be760cadcf36894d74b6f87ceba09 (diff) | |
download | neon-dde3eb8170932338a806f6a344083c8469204c62.tar.gz |
* src/ne_dates.c (ne_asctime_parse, ne_rfc1123_parse): Fail for sscanf
failure.
git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@2033 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'src/ne_dates.c')
-rw-r--r-- | src/ne_dates.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/ne_dates.c b/src/ne_dates.c index b621e7a..8a58a20 100644 --- a/src/ne_dates.c +++ b/src/ne_dates.c @@ -171,11 +171,12 @@ time_t ne_rfc1123_parse(const char *date) int n; time_t result; -/* it goes: Sun, 06 Nov 1994 08:49:37 GMT */ - n = sscanf(date, RFC1123_FORMAT, - wkday, &gmt.tm_mday, mon, &gmt.tm_year, &gmt.tm_hour, - &gmt.tm_min, &gmt.tm_sec); - /* Is it portable to check n==7 here? */ + /* it goes: Sun, 06 Nov 1994 08:49:37 GMT */ + if (sscanf(date, RFC1123_FORMAT, + wkday, &gmt.tm_mday, mon, &gmt.tm_year, &gmt.tm_hour, + &gmt.tm_min, &gmt.tm_sec) != 7) + return (time_t) -1; + gmt.tm_year -= 1900; for (n=0; n<12; n++) if (strcmp(mon, short_months[n]) == 0) @@ -204,7 +205,6 @@ time_t ne_rfc1036_parse(const char *date) return (time_t)-1; } - /* portable to check n here? */ for (n=0; n<12; n++) if (strcmp(mon, short_months[n]) == 0) break; @@ -232,11 +232,12 @@ time_t ne_asctime_parse(const char *date) char wkday[4], mon[4]; time_t result; - n = sscanf(date, ASCTIME_FORMAT, - wkday, mon, &gmt.tm_mday, - &gmt.tm_hour, &gmt.tm_min, &gmt.tm_sec, - &gmt.tm_year); - /* portable to check n here? */ + if (sscanf(date, ASCTIME_FORMAT, + wkday, mon, &gmt.tm_mday, + &gmt.tm_hour, &gmt.tm_min, &gmt.tm_sec, + &gmt.tm_year) != 7) + return (time_t)-1; + for (n=0; n<12; n++) if (strcmp(mon, short_months[n]) == 0) break; |