From 0ff1a4556c0a0fb76ce48e88031eff2b4d613c5e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 22 Feb 2011 11:26:47 +0100 Subject: =?UTF-8?q?*=20apt-pkg/contrib/fileutl.cc:=20=20=20-=20reorder=20t?= =?UTF-8?q?he=20loaded=20filesize=20bytes=20for=20big=20endian=20(Closes:?= =?UTF-8?q?=20#612986)=20=20=20=20=20Thanks=20to=20J=C3=B6rg=20Sommer=20fo?= =?UTF-8?q?r=20the=20detailed=20analyse!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apt-pkg/contrib/fileutl.cc | 14 +++++++++++++- debian/changelog | 6 +++++- 2 files changed, 18 insertions(+), 2 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 #include #include + +#include +#ifdef WORDS_BIGENDIAN +#include +#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"); diff --git a/debian/changelog b/debian/changelog index 364203044..b3907ac0f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,8 +9,12 @@ apt (0.8.10.3+squeeze1) UNRELEASED; urgency=low * Fix error in French translation of manpages (apt_preferences(5)). Merci, Rémi Vanicat. Closes: #613689 + [ David Kalnischkies ] + * apt-pkg/contrib/fileutl.cc: + - reorder the loaded filesize bytes for big endian (Closes: #612986) + Thanks to Jörg Sommer for the detailed analyse! - -- David Kalnischkies Tue, 22 Feb 2011 11:19:50 +0100 + -- David Kalnischkies Tue, 22 Feb 2011 11:25:58 +0100 apt (0.8.10.3) unstable; urgency=low -- cgit v1.2.3