cid#706201: No need to call access prior to realpath here
...and thus silence a TOCTOU warning Change-Id: I17f36181946616747d84aca6d43e44d180dc8741
This commit is contained in:
@@ -156,26 +156,21 @@ static char* platformSpecific(void)
|
|||||||
strcpy( file, dir );
|
strcpy( file, dir );
|
||||||
strcat( file, APPENDIX );
|
strcat( file, APPENDIX );
|
||||||
|
|
||||||
/* check existence of soffice file */
|
/* resolve symbolic link */
|
||||||
if ( !access( file, F_OK ) )
|
resolved = realpath( file, buffer );
|
||||||
|
if ( resolved != NULL )
|
||||||
{
|
{
|
||||||
/* resolve symbolic link */
|
/* get path to program directory */
|
||||||
resolved = realpath( file, buffer );
|
sep = strrchr( resolved, SEPARATOR );
|
||||||
|
|
||||||
if ( resolved != NULL )
|
if ( sep != NULL )
|
||||||
{
|
{
|
||||||
/* get path to program directory */
|
pos = sep - resolved;
|
||||||
sep = strrchr( resolved, SEPARATOR );
|
path = (char*) malloc( pos + 1 );
|
||||||
|
strncpy( path, resolved, pos );
|
||||||
if ( sep != NULL )
|
path[ pos ] = '\0';
|
||||||
{
|
free( file );
|
||||||
pos = sep - resolved;
|
break;
|
||||||
path = (char*) malloc( pos + 1 );
|
|
||||||
strncpy( path, resolved, pos );
|
|
||||||
path[ pos ] = '\0';
|
|
||||||
free( file );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user