From 234b6ffc2c39268d1efdc414e02bc4b352e5d931 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 29 Aug 2011 12:12:54 -0500 Subject: Parse > 2GiB file sizes correctly We were using atol(), which on 32 bit, cannot handle values greater than 2GiB, which is fail. Switch to a strtoull() wrapper function tailored toward parsing off_t values. This allows parsing of very large positive integer values. off_t is a signed type, but in our usages, we never parse or have a need for negative values, so the function will return -1 on error. Before: $ pacman -Si flightgear-data | grep Size Download Size : 2097152.00 K Installed Size : 2097152.00 K After: $ ./src/pacman/pacman -Si flightgear-data | grep Size Download Size : 2312592.52 KiB Installed Size : 5402896.00 KiB Signed-off-by: Dan McGee --- lib/libalpm/be_local.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libalpm/be_local.c') diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index be02bb50..dc9e361d 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -619,7 +619,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq) READ_AND_STORE(info->packager); } else if(strcmp(line, "%REASON%") == 0) { READ_NEXT(); - info->reason = (alpm_pkgreason_t)atol(line); + info->reason = (alpm_pkgreason_t)atoi(line); } else if(strcmp(line, "%SIZE%") == 0) { /* NOTE: the CSIZE and SIZE fields both share the "size" field * in the pkginfo_t struct. This can be done b/c CSIZE @@ -627,7 +627,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq) * only used in local databases. */ READ_NEXT(); - info->size = atol(line); + info->size = _alpm_strtoofft(line); /* also store this value to isize */ info->isize = info->size; } else if(strcmp(line, "%REPLACES%") == 0) { -- cgit v1.2.3-24-g4f1b