index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2011-09-07 09:32:23 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-10-12 14:01:25 -0500 |
commit | 759f435fb91a3abf64a422b53f939a774332cd8a (patch) | |
tree | fd9cf360304cc414a55fd50b66883aecf8f475de | |
parent | d3d3b861ac2c4ce63c306e00395945bfa3c1b6c6 (diff) |
-rw-r--r-- | lib/libalpm/util.c | 21 |
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index beefa936..243978cd 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -1109,6 +1109,10 @@ off_t _alpm_strtoofft(const char *line) time_t _alpm_parsedate(const char *line) { + char *end; + long long result; + errno = 0; + if(isalpha((unsigned char)line[0])) { /* initialize to null in case of failure */ struct tm tmp_tm; @@ -1118,7 +1122,22 @@ time_t _alpm_parsedate(const char *line) setlocale(LC_TIME, ""); return mktime(&tmp_tm); } - return (time_t)atol(line); + + result = strtoll(line, &end, 10); + if (result == 0 && end == line) { + /* line was not a number */ + errno = EINVAL; + return (time_t)0; + } else if (errno == ERANGE) { + /* line does not fit in long long */ + return (time_t)0; + } else if (*end) { + /* line began with a number but has junk left over at the end */ + errno = EINVAL; + return (time_t)0; + } + + return (time_t)result; } /** |