summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-02-14 11:20:48 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-02-14 11:20:48 +0100
commit2cae0ccb49efbeebe33f364b61e639ebf2639bdd (patch)
tree1e006d9f2fa044dca861d8e763555b87bf783ee2 /apt-pkg
parentf330c0f347619f72766069acdc24616ec5fe7147 (diff)
use inttypes to avoid suprises with different type sizes
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc10
1 files changed, 8 insertions, 2 deletions
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 <errno.h>
#include <set>
#include <algorithm>
+
+#ifndef WORDS_BIGENDIAN
+#include <inttypes.h>
+#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)