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 + debian/changelog | 3 ++- methods/rred.cc | 11 ++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) 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(); diff --git a/debian/changelog b/debian/changelog index f8d29abde..86d31d856 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,10 +9,11 @@ apt (0.8.12) unstable; urgency=low marker could be lost later by the removal of rdepends (Closes: #612557) * methods/rred.cc: - read patch into MMap only if we work on uncompressed patches + - update size of dynamic MMap as we write in from the outside * apt-pkg/contrib/mmap.cc: - do not try to free the mapping if its is unset - -- David Kalnischkies Sat, 12 Feb 2011 19:39:25 +0100 + -- David Kalnischkies Sun, 13 Feb 2011 11:36:11 +0100 apt (0.8.11.1) unstable; urgency=low diff --git a/methods/rred.cc b/methods/rred.cc index 80cd14986..9ad0e4464 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -255,9 +255,14 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/ MMap ed_cmds(MMap::ReadOnly); if (Patch.gzFd() != NULL) { unsigned long mapSize = Patch.Size(); - DynamicMMap dyn(0, mapSize, 0); - gzread(Patch.gzFd(), dyn.Data(), mapSize); - ed_cmds = dyn; + DynamicMMap* dyn = new DynamicMMap(0, mapSize, 0); + if (dyn->Data() == 0) { + delete dyn; + return MMAP_FAILED; + } + dyn->AddSize(mapSize); + gzread(Patch.gzFd(), dyn->Data(), mapSize); + ed_cmds = *dyn; } else ed_cmds = MMap(Patch, MMap::ReadOnly); -- cgit v1.2.3-70-g09d2