fix vips7 split on empty filename
a "" filename in vips7 compat mode could trigger a read beyond the end of the string see https://github.com/jcupitt/libvips/issues/1040
This commit is contained in:
parent
479610ff30
commit
b7bac0d88d
@ -79,12 +79,17 @@ void
|
||||
im_filename_split( const char *path, char *name, char *mode )
|
||||
{
|
||||
char *p;
|
||||
size_t len;
|
||||
|
||||
vips_strncpy( name, path, FILENAME_MAX );
|
||||
strcpy( mode, "" );
|
||||
|
||||
/* Search back towards start stopping at each ':' char.
|
||||
if( (len = strlen( name )) == 0 )
|
||||
return;
|
||||
|
||||
/* Search backwards towards start, stopping at each ':' char.
|
||||
*/
|
||||
for( p = name + strlen( name ) - 1; p > name; p -= 1 )
|
||||
for( p = name + len - 1; p > name; p -= 1 )
|
||||
if( *p == ':' ) {
|
||||
char *q;
|
||||
|
||||
@ -120,8 +125,6 @@ im_filename_split( const char *path, char *name, char *mode )
|
||||
vips_strncpy( mode, p + 1, FILENAME_MAX );
|
||||
*p = '\0';
|
||||
}
|
||||
else
|
||||
strcpy( mode, "" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user