[Libreoffice-commits] core.git: vcl/generic

Eike Rathke erack at redhat.com
Sat Mar 30 11:39:52 PDT 2013


 vcl/generic/fontmanager/fontmanager.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2cd4e55bb36a9a3d13971b530469188e3fb59dfe
Author: Eike Rathke <erack at redhat.com>
Date:   Sat Mar 30 19:23:55 2013 +0100

    certainly this was not meant to be _PC_NAME_MAX
    
    _PC_NAME_MAX is a symbolic constant meant to be used as a pathconf()
    argument, not a buffer length.
    
    This piece of code was even "honored" in
    http://womble.decadent.org.uk/readdir_r-advisory.html
    "The code that enumerates fonts and plugins in the appropriate
    directories uses a stack buffer of type long[sizeof(struct dirent) +
    _PC_NAME_MAX + 1]. I can only assume this is the result of a programmer
    cutting his crack with aluminium filings."
    
    Thanks to Heiner Rechtien for pointing this out.
    
    Note: declaring the buffer of type long instead of char looks weird but
    probably has the reason that it is casted to struct dirent* for the
    readdir_r() call that might not work on architectures that forbid
    arbitrary alignment on non-even boundaries.
    
    Change-Id: Ie959b8905d1328c6fcaefbf6f6c915cc430e85b6

diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index c5a52f7..de66c52 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -1637,7 +1637,7 @@ void PrintFontManager::initialize()
     CALLGRIND_ZERO_STATS();
     #endif
 
-    long aDirEntBuffer[ (sizeof(struct dirent)+_PC_NAME_MAX)+1 ];
+    long aDirEntBuffer[ (sizeof(struct dirent)+PATH_MAX)+1 ];
 
     if( ! m_pFontCache )
     {


More information about the Libreoffice-commits mailing list