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