summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorAdam Conrad <adconrad@debian.org>2014-04-26 10:24:40 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2014-04-26 10:47:29 +0200
commit05eab8afb692823f86c53c4c2ced783a7c185cf9 (patch)
treee7af1fece550d0777899be6e519adfbdfb36df27 /apt-pkg
parent062074cb519aa05110d24936d95747c59cc0ffc1 (diff)
fix FileFd::Size bitswap on big-endian architectures
gzip only gives us 32bit of size, storing it in a 64bit container and doing a 32bit flip on it has therefore unintended results. So we just go with a exact size container and let the flipping be handled by eglibc provided le32toh removing our #ifdef machinery. Closes: 745866
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc17
1 files changed, 4 insertions, 13 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index de73a7fd8..b77c7ff7f 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -58,13 +58,10 @@
#include <bzlib.h>
#endif
#ifdef HAVE_LZMA
- #include <stdint.h>
#include <lzma.h>
#endif
-
-#ifdef WORDS_BIGENDIAN
-#include <inttypes.h>
-#endif
+#include <endian.h>
+#include <stdint.h>
#include <apti18n.h>
/*}}}*/
@@ -1880,19 +1877,13 @@ unsigned long long FileFd::Size()
FileFdErrno("lseek","Unable to seek to end of gzipped file");
return 0;
}
- size = 0;
+ uint32_t size = 0;
if (read(iFd, &size, 4) != 4)
{
FileFdErrno("read","Unable to read original size of gzipped file");
return 0;
}
-
-#ifdef WORDS_BIGENDIAN
- uint32_t tmp_size = size;
- uint8_t const * const p = (uint8_t const * const) &tmp_size;
- tmp_size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
- size = tmp_size;
-#endif
+ size = le32toh(size);
if (lseek(iFd, oldPos, SEEK_SET) < 0)
{