5d880b1
From d11f2ccdcecca78bc654ca0b787ea112c1dfe10c Mon Sep 17 00:00:00 2001
5d880b1
From: Stephan Bergmann <sbergman@redhat.com>
5d880b1
Date: Thu, 15 Dec 2011 11:57:08 +0100
5d880b1
Subject: [PATCH] Resolves: rhbz#767708 avoid SIGBUS writing to overcommitted
5d880b1
 mmaped diskspace
5d880b1
5d880b1
---
5d880b1
 bridges/source/cpp_uno/shared/vtablefactory.cxx |   10 ++++++++--
5d880b1
 1 files changed, 8 insertions(+), 2 deletions(-)
5d880b1
5d880b1
diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx
5d880b1
index 2703ac0..b049c7f 100644
5d880b1
--- a/bridges/source/cpp_uno/shared/vtablefactory.cxx
5d880b1
+++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx
5d880b1
@@ -65,6 +66,10 @@
5d880b1
 #error Unsupported platform
5d880b1
 #endif
5d880b1
 
5d880b1
+#if defined USE_DOUBLE_MMAP
5d880b1
+#include <fcntl.h>
5d880b1
+#endif
5d880b1
+
5d880b1
 using bridges::cpp_uno::shared::VtableFactory;
5d880b1
 
5d880b1
 namespace {
5d880b1
@@ -259,9 +264,10 @@ bool VtableFactory::createBlock(Block &block, sal_Int32 slotCount) const
5d880b1
         }
5d880b1
         unlink(tmpfname);
5d880b1
         delete[] tmpfname;
5d880b1
-        if (ftruncate(block.fd, block.size) == -1)
5d880b1
+        int err = posix_fallocate(block.fd, 0, block.size);
5d880b1
+        if (err != 0)
5d880b1
         {
5d880b1
-            perror("truncation of executable memory area failed");
5d880b1
+            fprintf(stderr, "posix_fallocate failed with code %d\n", err);
5d880b1
             close(block.fd);
5d880b1
             block.fd = -1;
5d880b1
             break;
5d880b1
-- 
5d880b1
1.7.7.4
5d880b1