]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Check that we do not overflow mmap(2) size argument.
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 14 Apr 2011 20:35:30 +0000 (14:35 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 14 Apr 2011 20:35:30 +0000 (14:35 -0600)
src/ipc/mem/Segment.cc

index 3c0305fe37608b6948ba50dee99438dcf068e8d6..1b059fba77c33356cc75303fff45a8d1a2cabdf8 100644 (file)
@@ -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<off_t>(static_cast<size_t>(theSize)));
+
     void *const p =
         mmap(NULL, theSize, PROT_READ | PROT_WRITE, MAP_SHARED, theFD, 0);
     if (p == MAP_FAILED) {