diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-11-18 11:26:15 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-11-18 12:17:18 +0100 |
commit | 11b0ce9bab436eec81534e9a82bfe76e69b0cf41 (patch) | |
tree | f5ab83909b95b6f0417e1721b4a7843354cd40d0 /cppuhelper | |
parent | 0bb0522b21cd0f43c295606d63059730c04dab14 (diff) |
cid#706201: No need to call access prior to realpath here
...and thus silence a TOCTOU warning
Change-Id: I17f36181946616747d84aca6d43e44d180dc8741
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/source/findsofficepath.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/cppuhelper/source/findsofficepath.c b/cppuhelper/source/findsofficepath.c index f062d8f30e78..37c8bdfc5e07 100644 --- a/cppuhelper/source/findsofficepath.c +++ b/cppuhelper/source/findsofficepath.c @@ -156,26 +156,21 @@ static char* platformSpecific(void) strcpy( file, dir ); strcat( file, APPENDIX ); - /* check existence of soffice file */ - if ( !access( file, F_OK ) ) + /* resolve symbolic link */ + resolved = realpath( file, buffer ); + if ( resolved != NULL ) { - /* resolve symbolic link */ - resolved = realpath( file, buffer ); + /* get path to program directory */ + sep = strrchr( resolved, SEPARATOR ); - if ( resolved != NULL ) + if ( sep != NULL ) { - /* get path to program directory */ - sep = strrchr( resolved, SEPARATOR ); - - if ( sep != NULL ) - { - pos = sep - resolved; - path = (char*) malloc( pos + 1 ); - strncpy( path, resolved, pos ); - path[ pos ] = '\0'; - free( file ); - break; - } + pos = sep - resolved; + path = (char*) malloc( pos + 1 ); + strncpy( path, resolved, pos ); + path[ pos ] = '\0'; + free( file ); + break; } } |