diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2016-03-28 22:08:25 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2016-03-28 22:08:25 +0100 |
commit | 24f351bda04a0a6198336981c54c5438c6dad723 (patch) | |
tree | d7bed69878d0e28ce49dd409baea9b5c11f7864b /sal | |
parent | ec60e33dd83b1bdec01b2c4a1dbaa15e92c9f6b5 (diff) |
handle failure to expand ~ in path elements.
This can occur in some online corner-cases.
Change-Id: Id8b419179d775a21110d682ba76d8a02f45eb828
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/file_url.cxx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx index 742b3f5a6a29..af9abbe0d79b 100644 --- a/sal/osl/unx/file_url.cxx +++ b/sal/osl/unx/file_url.cxx @@ -255,20 +255,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 */ |