summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-02-22 11:26:47 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-02-22 11:26:47 +0100
commit0ff1a4556c0a0fb76ce48e88031eff2b4d613c5e (patch)
tree1a76a7df41d07a08a1627315a491083d940f24a1 /apt-pkg
parenta7476cb43894d6d019d6ecde31ff418fc472c2b6 (diff)
* apt-pkg/contrib/fileutl.cc:
- reorder the loaded filesize bytes for big endian (Closes: #612986) Thanks to Jörg Sommer for the detailed analyse!
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index f4ab066d7..266d480a4 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -42,6 +42,11 @@
#include <errno.h>
#include <set>
#include <algorithm>
+
+#include <config.h>
+#ifdef WORDS_BIGENDIAN
+#include <inttypes.h>
+#endif
/*}}}*/
using namespace std;
@@ -940,9 +945,16 @@ unsigned long FileFd::Size()
off_t orig_pos = lseek(iFd, 0, SEEK_CUR);
if (lseek(iFd, -4, SEEK_END) < 0)
return _error->Errno("lseek","Unable to seek to end of gzipped file");
+ size = 0L;
if (read(iFd, &size, 4) != 4)
return _error->Errno("read","Unable to read original size of gzipped file");
- size &= 0xFFFFFFFF;
+
+#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
if (lseek(iFd, orig_pos, SEEK_SET) < 0)
return _error->Errno("lseek","Unable to seek in gzipped file");