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

Michael Meeks michael.meeks at collabora.com
Tue Mar 29 10:05:34 UTC 2016


 framework/source/services/substitutepathvars.cxx |    8 ++++----
 sal/osl/unx/file_url.cxx                         |    7 +++++--
 2 files changed, 9 insertions(+), 6 deletions(-)

New commits:
commit 017a864caf4c57f1dcff28fce824f2a41ea6e027
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Mar 28 22:02:41 2016 +0100

    handle failure to expand ~ in path elements.
    
    This can occur in some online corner-cases.
    
    Change-Id: Id8b419179d775a21110d682ba76d8a02f45eb828
    Reviewed-on: https://gerrit.libreoffice.org/23577
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index 17375a4..3827e32 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -822,9 +822,8 @@ OUString SubstitutePathVariables::GetHomeVariableValue() const
 
 OUString SubstitutePathVariables::GetPathVariableValue() const
 {
-
     OUString aRetStr;
-    const char*   pEnv = getenv( "PATH" );
+    const char* pEnv = getenv( "PATH" );
 
     if ( pEnv )
     {
@@ -838,9 +837,10 @@ OUString SubstitutePathVariables::GetPathVariableValue() const
         do
         {
             OUString sToken = aPathList.getToken(0, SAL_PATHSEPARATOR, nToken);
-            if (!sToken.isEmpty())
+            if (!sToken.isEmpty() &&
+                osl::FileBase::getFileURLFromSystemPath( sToken, aTmp ) ==
+                osl::FileBase::RC::E_None )
             {
-                osl::FileBase::getFileURLFromSystemPath( sToken, aTmp );
                 if ( bAppendSep )
                     aPathStrBuffer.append( ";" ); // Office uses ';' as path separator
                 aPathStrBuffer.append( aTmp );
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index cc9907a..6c279f5 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -257,20 +257,23 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( rtl_uString *ustrSystemPath,
     if( '~' == ustrSystemPath->buffer[0] )
     {
         /* check if another user is specified */
-        if( ( 1 == ustrSystemPath->length ) || ( '/' == ustrSystemPath->buffer[1] ) )
+        if( ( 1 == ustrSystemPath->length ) ||
+            ( '/' == ustrSystemPath->buffer[1] ) )
         {
             /* osl_getHomeDir returns file URL */
             oslSecurity pSecurity = osl_getCurrentSecurity();
             osl_getHomeDir( pSecurity , &pTmp );
             osl_freeSecurityHandle( pSecurity );
 
+            if (!pTmp)
+                return osl_File_E_INVAL;
+
             /* remove "file://" prefix */
             rtl_uString_newFromStr_WithLength( &pTmp, pTmp->buffer + 7, pTmp->length - 7 );
 
             /* replace '~' in original string */
             rtl_uString_newReplaceStrAt( &pTmp, ustrSystemPath, 0, 1, pTmp );
         }
-
         else
         {
             /* FIXME: replace ~user with users home directory */


More information about the Libreoffice-commits mailing list