[Libreoffice-commits] core.git: sal/osl

Stephan Bergmann sbergman at redhat.com
Thu Feb 23 11:10:43 UTC 2017


 sal/osl/unx/file_volume.cxx |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 280cd27dbdab438e63ecb2599ab5dd20e04d71d5
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Feb 23 12:10:08 2017 +0100

    -Werror=format-truncation
    
    Change-Id: I1b27289724389018bd4048573e8c8e4cf28eb983

diff --git a/sal/osl/unx/file_volume.cxx b/sal/osl/unx/file_volume.cxx
index 0940eab..5462368 100644
--- a/sal/osl/unx/file_volume.cxx
+++ b/sal/osl/unx/file_volume.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <cassert>
+
 #include "osl/file.h"
 
 #include "osl/diagnose.h"
@@ -353,7 +357,7 @@ static rtl_uString* oslMakeUStrFromPsz(const sal_Char* pszStr, rtl_uString** ust
 oslFileError osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath )
 {
     oslVolumeDeviceHandleImpl* pItem = static_cast<oslVolumeDeviceHandleImpl*>(Handle);
-    sal_Char Buffer[PATH_MAX];
+    sal_Char Buffer[RTL_CONSTASCII_LENGTH("file://") + PATH_MAX];
 
     Buffer[0] = '\0';
 
@@ -367,7 +371,8 @@ oslFileError osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uSt
         return osl_File_E_INVAL;
     }
 
-    snprintf(Buffer, sizeof(Buffer), "file://%s", pItem->pszMountPoint);
+    int n = snprintf(Buffer, sizeof(Buffer), "file://%s", pItem->pszMountPoint);
+    assert(n >= 0 && unsigned(n) < sizeof(Buffer)); (void) n;
 
 #ifdef DEBUG_OSL_FILE
     fprintf(stderr,"Mount Point is: '%s'\n",Buffer);


More information about the Libreoffice-commits mailing list