1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-01 07:14:31 +00:00

mountmgr: Replace some malloc/sprintf/strcpy calls with asprintf.

This commit is contained in:
Brendan Shanks 2024-03-11 11:55:44 -07:00 committed by Alexandre Julliard
parent a5b8e68422
commit 3af1e7df21

View File

@ -89,22 +89,14 @@ static NTSTATUS errno_to_status( int err )
static char *get_dosdevices_path( const char *dev )
{
const char *home = getenv( "HOME" );
const char *prefix = getenv( "WINEPREFIX" );
size_t len = (prefix ? strlen(prefix) : strlen(home) + strlen("/.wine")) + sizeof("/dosdevices/") + strlen(dev);
char *path = malloc( len );
char *path = NULL;
if (prefix)
asprintf( &path, "%s/dosdevices/%s", prefix, dev );
else
asprintf( &path, "%s/.wine/dosdevices/%s", getenv( "HOME" ), dev );
if (path)
{
if (prefix) strcpy( path, prefix );
else
{
strcpy( path, home );
strcat( path, "/.wine" );
}
strcat( path, "/dosdevices/" );
strcat( path, dev );
}
return path;
}
@ -420,9 +412,9 @@ static NTSTATUS read_volume_file( void *args )
{
const struct read_volume_file_params *params = args;
int ret, fd = -1;
char *name = malloc( strlen(params->volume) + strlen(params->file) + 2 );
char *name = NULL;
sprintf( name, "%s/%s", params->volume, params->file );
asprintf( &name, "%s/%s", params->volume, params->file );
if (name[0] != '/')
{
@ -508,9 +500,7 @@ static NTSTATUS set_shell_folder( void *args )
if (link && (!strcmp( link, "$HOME" ) || !strncmp( link, "$HOME/", 6 )) && (home = getenv( "HOME" )))
{
link += 5;
homelink = malloc( strlen(home) + strlen(link) + 1 );
strcpy( homelink, home );
strcat( homelink, link );
asprintf( &homelink, "%s%s", home, link );
link = homelink;
}