From 26b37f959350860a0c1d5ef9651efa0bf3640cb5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 12 Feb 2011 19:40:47 +0100 Subject: * apt-pkg/contrib/mmap.cc: - do not try to free the mapping if its is unset --- apt-pkg/contrib/mmap.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 69fb61fca..4978446d2 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -266,6 +266,8 @@ DynamicMMap::~DynamicMMap() { if (Fd == 0) { + if (Base == 0) + return; #ifdef _POSIX_MAPPED_FILES munmap(Base, WorkSpace); #else -- cgit v1.2.3 From 005428387832e79e314bb8f2605f7e6c69708d14 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 13 Feb 2011 11:37:22 +0100 Subject: update size of dynamic MMap as we write in from the outside --- apt-pkg/contrib/mmap.h | 1 + 1 file changed, 1 insertion(+) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h index 5ca951204..e9baa9339 100644 --- a/apt-pkg/contrib/mmap.h +++ b/apt-pkg/contrib/mmap.h @@ -61,6 +61,7 @@ class MMap inline operator void *() {return Base;}; inline void *Data() {return Base;}; inline unsigned long Size() {return iSize;}; + inline void AddSize(unsigned long const size) {iSize += size;}; // File manipulators bool Sync(); -- cgit v1.2.3 From f330c0f347619f72766069acdc24616ec5fe7147 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 13 Feb 2011 13:06:03 +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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 52f517ee0..6a621e2a9 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -962,9 +962,14 @@ 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 + unsigned char const * const p = (unsigned char *) &size; + size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]; +#endif if (lseek(iFd, orig_pos, SEEK_SET) < 0) return _error->Errno("lseek","Unable to seek in gzipped file"); -- cgit v1.2.3 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