From: Alex Rousskov Date: Thu, 14 Apr 2011 20:35:30 +0000 (-0600) Subject: Check that we do not overflow mmap(2) size argument. X-Git-Tag: take06~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3a2ede14d7112a32d5d6d35a269e6e00f30cb3a0;p=thirdparty%2Fsquid.git Check that we do not overflow mmap(2) size argument. --- diff --git a/src/ipc/mem/Segment.cc b/src/ipc/mem/Segment.cc index 3c0305fe37..1b059fba77 100644 --- a/src/ipc/mem/Segment.cc +++ b/src/ipc/mem/Segment.cc @@ -85,6 +85,10 @@ Ipc::Mem::Segment::attach() assert(theFD >= 0); assert(!theMem); + // mmap() accepts size_t for the size; we give it off_t which might + // be bigger; assert overflows until we support multiple mmap()s? + assert(theSize == static_cast(static_cast(theSize))); + void *const p = mmap(NULL, theSize, PROT_READ | PROT_WRITE, MAP_SHARED, theFD, 0); if (p == MAP_FAILED) {