Commit 3af1e7df authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

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

parent a5b8e684
......@@ -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 (path)
{
if (prefix) strcpy( path, prefix );
if (prefix)
asprintf( &path, "%s/dosdevices/%s", prefix, dev );
else
{
strcpy( path, home );
strcat( path, "/.wine" );
}
strcat( path, "/dosdevices/" );
strcat( path, dev );
}
asprintf( &path, "%s/.wine/dosdevices/%s", getenv( "HOME" ), 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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment