From 2cae0ccb49efbeebe33f364b61e639ebf2639bdd Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 14 Feb 2011 11:20:48 +0100 Subject: use inttypes to avoid suprises with different type sizes --- apt-pkg/contrib/fileutl.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 6a621e2a9..24e3f08d9 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -42,6 +42,10 @@ #include #include #include + +#ifndef WORDS_BIGENDIAN +#include +#endif /*}}}*/ using namespace std; @@ -967,8 +971,10 @@ unsigned long FileFd::Size() return _error->Errno("read","Unable to read original size of gzipped file"); #ifdef WORDS_BIGENDIAN - unsigned char const * const p = (unsigned char *) &size; - size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]; + 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 if (lseek(iFd, orig_pos, SEEK_SET) < 0) -- cgit v1.2.3