[pacman-dev] [PATCH 1/2] Add pactest for overflowing date (year 2038 problem)
This will work fine on x86_64 (or any platform that has a 64 bit long), but currently fails on i686. This test also stresses the recent changes to accommodate package size values greater than a 32 bit UINT_MAX. Signed-off-by: Dan McGee <dan@archlinux.org> --- test/pacman/tests/query002.py | 4 ++-- test/pacman/tests/query005.py | 4 ++-- test/pacman/tests/query006.py | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 test/pacman/tests/query006.py diff --git a/test/pacman/tests/query002.py b/test/pacman/tests/query002.py index 72fd7c1..ccf18f4 100644 --- a/test/pacman/tests/query002.py +++ b/test/pacman/tests/query002.py @@ -1,4 +1,4 @@ -self.description = "Query info on a package" +self.description = "Query info on a package (old date)" p = pmpkg("foobar") p.files = ["bin/foobar"] @@ -18,4 +18,4 @@ self.addrule("PACMAN_RETCODE=0") self.addrule("PACMAN_OUTPUT=^Name.*%s" % p.name) self.addrule("PACMAN_OUTPUT=^Description.*%s" % p.desc) -self.addrule("PACMAN_OUTPUT=^Build Date.*2007") +self.addrule("PACMAN_OUTPUT=^Build Date.* 2007") diff --git a/test/pacman/tests/query005.py b/test/pacman/tests/query005.py index 23a78fc..06768b3 100644 --- a/test/pacman/tests/query005.py +++ b/test/pacman/tests/query005.py @@ -1,4 +1,4 @@ -self.description = "Query info on a package" +self.description = "Query info on a package (new date)" p = pmpkg("foobar") p.files = ["bin/foobar"] @@ -18,4 +18,4 @@ self.addrule("PACMAN_RETCODE=0") self.addrule("PACMAN_OUTPUT=^Name.*%s" % p.name) self.addrule("PACMAN_OUTPUT=^Description.*%s" % p.desc) -self.addrule("PACMAN_OUTPUT=^Build Date.*2007") +self.addrule("PACMAN_OUTPUT=^Build Date.* 2007") diff --git a/test/pacman/tests/query006.py b/test/pacman/tests/query006.py new file mode 100644 index 0000000..3668478 --- /dev/null +++ b/test/pacman/tests/query006.py @@ -0,0 +1,27 @@ +self.description = "Query info on a package (overflow long values)" + +p = pmpkg("overflow") +p.desc = "Overflow size and date values if possible" +p.url = "http://www.archlinux.org" +p.license = "GPL2" +p.arch = "i686" +p.packager = "Arch Linux" +# size is greater than 4294967295, aka UINT_MAX +p.size = "10000000000" +# build date is greater than 2147483647, aka INT_MAX +p.builddate = "3000000000" +# install date is greater than UINT_MAX +p.installdate = "10000000000" + +self.addpkg2db("local", p) + +self.args = "-Qi %s" % p.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PACMAN_OUTPUT=^Name.*%s" % p.name) +self.addrule("PACMAN_OUTPUT=^Description.*%s" % p.desc) +self.addrule("PACMAN_OUTPUT=^Installed Size.*9765625.00 KiB") +self.addrule("PACMAN_OUTPUT=^Build Date.* 2065") +self.addrule("PACMAN_OUTPUT=^Install Date.* 2286") + +self.expectfailure = True -- 1.7.6
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/util.c | 4 ++-- lib/libalpm/util.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 4cb31a8..9bbac43 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -1099,7 +1099,7 @@ off_t _alpm_strtoofft(const char *line) return (off_t)result; } -long _alpm_parsedate(const char *line) +time_t _alpm_parsedate(const char *line) { if(isalpha((unsigned char)line[0])) { /* initialize to null in case of failure */ @@ -1109,7 +1109,7 @@ long _alpm_parsedate(const char *line) setlocale(LC_TIME, ""); return mktime(&tmp_tm); } - return atol(line); + return (time_t)atol(line); } /** diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index c5544a0..2a2d3a9 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -120,7 +120,7 @@ int _alpm_splitname(const char *target, char **name, char **version, unsigned long *name_hash); unsigned long _alpm_hash_sdbm(const char *str); off_t _alpm_strtoofft(const char *line); -long _alpm_parsedate(const char *line); +time_t _alpm_parsedate(const char *line); int _alpm_raw_cmp(const char *first, const char *second); int _alpm_raw_ncmp(const char *first, const char *second, size_t max); int _alpm_access(alpm_handle_t *handle, const char *dir, const char *file, int amode); -- 1.7.6
participants (1)
-
Dan McGee