From 2a79d5b560398427f5538865099b6777128d8bed Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 14 Feb 2011 17:03:35 +0100 Subject: [PATCH] * apt-pkg/contrib/fileutl.cc: - really detect bigendian machines by including config.h, so we can really (Closes: #612986) * apt-pkg/contrib/mmap.cc: - Base has as 'valid' failure states 0 and -1 so add a simple validData method to check for failure states --- apt-pkg/contrib/fileutl.cc | 3 ++- apt-pkg/contrib/mmap.cc | 4 ++-- apt-pkg/contrib/mmap.h | 1 + debian/changelog | 12 ++++++++++++ methods/rred.cc | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 24e3f08d9..767951daf 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -43,7 +43,8 @@ #include #include -#ifndef WORDS_BIGENDIAN +#include +#ifdef WORDS_BIGENDIAN #include #endif /*}}}*/ diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 4978446d2..9945b1606 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -106,7 +106,7 @@ bool MMap::Map(FileFd &Fd) /* */ bool MMap::Close(bool DoSync) { - if ((Flags & UnMapped) == UnMapped || Base == 0 || iSize == 0) + if ((Flags & UnMapped) == UnMapped || validData() == false || iSize == 0) return true; if (DoSync == true) @@ -266,7 +266,7 @@ DynamicMMap::~DynamicMMap() { if (Fd == 0) { - if (Base == 0) + if (validData() == false) return; #ifdef _POSIX_MAPPED_FILES munmap(Base, WorkSpace); diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h index e9baa9339..2bf2c1540 100644 --- a/apt-pkg/contrib/mmap.h +++ b/apt-pkg/contrib/mmap.h @@ -62,6 +62,7 @@ class MMap inline void *Data() {return Base;}; inline unsigned long Size() {return iSize;}; inline void AddSize(unsigned long const size) {iSize += size;}; + inline bool validData() const { return Base != (void *)-1 && Base != 0; }; // File manipulators bool Sync(); diff --git a/debian/changelog b/debian/changelog index 8e05f1220..99eb47858 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +apt (0.8.11.3) UNRELEASED; urgency=low + + [ David Kalnischkies ] + * apt-pkg/contrib/fileutl.cc: + - really detect bigendian machines by including config.h, + so we can really (Closes: #612986) + * apt-pkg/contrib/mmap.cc: + - Base has as 'valid' failure states 0 and -1 so add a simple + validData method to check for failure states + + -- David Kalnischkies Mon, 14 Feb 2011 16:58:03 +0100 + apt (0.8.11.2) unstable; urgency=low [ Michael Vogt ] diff --git a/methods/rred.cc b/methods/rred.cc index 9ad0e4464..849973e1a 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -256,7 +256,7 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/ if (Patch.gzFd() != NULL) { unsigned long mapSize = Patch.Size(); DynamicMMap* dyn = new DynamicMMap(0, mapSize, 0); - if (dyn->Data() == 0) { + if (dyn->validData() == false) { delete dyn; return MMAP_FAILED; } -- 2.45.2