Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
cd763004
Commit
cd763004
authored
Nov 02, 2023
by
Brendan Shanks
Committed by
Alexandre Julliard
Nov 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/unix: Replace some malloc/sprintf calls with asprintf.
parent
f0b2e0d0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
46 deletions
+29
-46
env.c
dlls/ntdll/unix/env.c
+3
-7
file.c
dlls/ntdll/unix/file.c
+4
-10
loader.c
dlls/ntdll/unix/loader.c
+9
-12
server.c
dlls/ntdll/unix/server.c
+13
-17
No files found.
dlls/ntdll/unix/env.c
View file @
cd763004
...
@@ -108,8 +108,7 @@ static char *get_nls_file_path( UINT type, UINT id )
...
@@ -108,8 +108,7 @@ static char *get_nls_file_path( UINT type, UINT id )
break
;
break
;
}
}
if
(
!
name
)
return
NULL
;
if
(
!
name
)
return
NULL
;
if
(
!
(
path
=
malloc
(
strlen
(
dir
)
+
strlen
(
name
)
+
10
)))
return
NULL
;
if
(
asprintf
(
&
path
,
"%s/nls/%s.nls"
,
dir
,
name
)
==
-
1
)
return
NULL
;
sprintf
(
path
,
"%s/nls/%s.nls"
,
dir
,
name
);
return
path
;
return
path
;
}
}
...
@@ -121,8 +120,7 @@ static void *read_nls_file( const char *name )
...
@@ -121,8 +120,7 @@ static void *read_nls_file( const char *name )
void
*
data
,
*
ret
=
NULL
;
void
*
data
,
*
ret
=
NULL
;
int
fd
;
int
fd
;
if
(
!
(
path
=
malloc
(
strlen
(
dir
)
+
strlen
(
name
)
+
10
)))
return
NULL
;
if
(
asprintf
(
&
path
,
"%s/nls/%s"
,
dir
,
name
)
==
-
1
)
return
NULL
;
sprintf
(
path
,
"%s/nls/%s"
,
dir
,
name
);
if
((
fd
=
open
(
path
,
O_RDONLY
))
!=
-
1
)
if
((
fd
=
open
(
path
,
O_RDONLY
))
!=
-
1
)
{
{
...
@@ -2238,9 +2236,7 @@ NTSTATUS WINAPI NtInitializeNlsFiles( void **ptr, LCID *lcid, LARGE_INTEGER *siz
...
@@ -2238,9 +2236,7 @@ NTSTATUS WINAPI NtInitializeNlsFiles( void **ptr, LCID *lcid, LARGE_INTEGER *siz
SIZE_T
mapsize
;
SIZE_T
mapsize
;
NTSTATUS
status
;
NTSTATUS
status
;
if
(
!
(
path
=
malloc
(
strlen
(
dir
)
+
sizeof
(
"/nls/locale.nls"
)
)))
return
STATUS_NO_MEMORY
;
if
(
asprintf
(
&
path
,
"%s/nls/locale.nls"
,
dir
)
==
-
1
)
return
STATUS_NO_MEMORY
;
strcpy
(
path
,
dir
);
strcat
(
path
,
"/nls/locale.nls"
);
status
=
open_nls_data_file
(
path
,
system_dir
,
&
file
);
status
=
open_nls_data_file
(
path
,
system_dir
,
&
file
);
free
(
path
);
free
(
path
);
if
(
!
status
)
if
(
!
status
)
...
...
dlls/ntdll/unix/file.c
View file @
cd763004
...
@@ -2098,10 +2098,8 @@ static unsigned int get_drives_info( struct file_identity info[MAX_DOS_DRIVES] )
...
@@ -2098,10 +2098,8 @@ static unsigned int get_drives_info( struct file_identity info[MAX_DOS_DRIVES] )
struct
stat
st
;
struct
stat
st
;
unsigned
int
i
;
unsigned
int
i
;
if
(
(
buffer
=
malloc
(
strlen
(
config_dir
)
+
sizeof
(
"/dosdevices/a:"
)
))
)
if
(
asprintf
(
&
buffer
,
"%s/dosdevices/a:"
,
config_dir
)
!=
-
1
)
{
{
strcpy
(
buffer
,
config_dir
);
strcat
(
buffer
,
"/dosdevices/a:"
);
p
=
buffer
+
strlen
(
buffer
)
-
2
;
p
=
buffer
+
strlen
(
buffer
)
-
2
;
for
(
i
=
nb_drives
=
0
;
i
<
MAX_DOS_DRIVES
;
i
++
)
for
(
i
=
nb_drives
=
0
;
i
<
MAX_DOS_DRIVES
;
i
++
)
...
@@ -2898,9 +2896,7 @@ static void init_redirects(void)
...
@@ -2898,9 +2896,7 @@ static void init_redirects(void)
char
*
dir
;
char
*
dir
;
struct
stat
st
;
struct
stat
st
;
if
(
!
(
dir
=
malloc
(
strlen
(
config_dir
)
+
sizeof
(
system_dir
)
)))
return
;
if
(
asprintf
(
&
dir
,
"%s%s"
,
config_dir
,
system_dir
)
==
-
1
)
return
;
strcpy
(
dir
,
config_dir
);
strcat
(
dir
,
system_dir
);
if
(
!
stat
(
dir
,
&
st
))
if
(
!
stat
(
dir
,
&
st
))
{
{
sysdir
.
dev
=
st
.
st_dev
;
sysdir
.
dev
=
st
.
st_dev
;
...
@@ -3904,11 +3900,9 @@ static NTSTATUS unmount_device( HANDLE handle )
...
@@ -3904,11 +3900,9 @@ static NTSTATUS unmount_device( HANDLE handle )
#else
#else
static
const
char
umount
[]
=
"umount >/dev/null 2>&1 "
;
static
const
char
umount
[]
=
"umount >/dev/null 2>&1 "
;
#endif
#endif
char
*
cmd
=
malloc
(
strlen
(
mount_point
)
+
sizeof
(
umount
))
;
char
*
cmd
;
if
(
cmd
)
if
(
asprintf
(
&
cmd
,
"%s%s"
,
umount
,
mount_point
)
!=
-
1
)
{
{
strcpy
(
cmd
,
umount
);
strcat
(
cmd
,
mount_point
);
system
(
cmd
);
system
(
cmd
);
free
(
cmd
);
free
(
cmd
);
#ifdef linux
#ifdef linux
...
...
dlls/ntdll/unix/loader.c
View file @
cd763004
...
@@ -663,9 +663,7 @@ static void init_paths( char *argv[] )
...
@@ -663,9 +663,7 @@ static void init_paths( char *argv[] )
}
}
else
wineloader
=
build_path
(
build_path
(
build_dir
,
"loader"
),
basename
);
else
wineloader
=
build_path
(
build_path
(
build_dir
,
"loader"
),
basename
);
env
=
malloc
(
sizeof
(
"WINELOADER="
)
+
strlen
(
wineloader
)
);
asprintf
(
&
env
,
"WINELOADER=%s"
,
wineloader
);
strcpy
(
env
,
"WINELOADER="
);
strcat
(
env
,
wineloader
);
putenv
(
env
);
putenv
(
env
);
set_dll_path
();
set_dll_path
();
...
@@ -1835,18 +1833,18 @@ static void load_ntdll(void)
...
@@ -1835,18 +1833,18 @@ static void load_ntdll(void)
UNICODE_STRING
str
;
UNICODE_STRING
str
;
void
*
module
;
void
*
module
;
SIZE_T
size
=
0
;
SIZE_T
size
=
0
;
char
*
name
;
char
*
name
=
NULL
;
init_unicode_string
(
&
str
,
path
);
init_unicode_string
(
&
str
,
path
);
InitializeObjectAttributes
(
&
attr
,
&
str
,
0
,
0
,
NULL
);
InitializeObjectAttributes
(
&
attr
,
&
str
,
0
,
0
,
NULL
);
name
=
malloc
(
strlen
(
ntdll_dir
)
+
strlen
(
pe_dir
)
+
sizeof
(
"/ntdll.dll.so"
)
);
if
(
build_dir
)
asprintf
(
&
name
,
"%s%s/ntdll.dll"
,
ntdll_dir
,
pe_dir
);
if
(
build_dir
)
sprintf
(
name
,
"%s%s/ntdll.dll"
,
ntdll_dir
,
pe_dir
);
else
asprintf
(
&
name
,
"%s%s/ntdll.dll"
,
dll_dir
,
pe_dir
);
else
sprintf
(
name
,
"%s%s/ntdll.dll"
,
dll_dir
,
pe_dir
);
status
=
open_builtin_pe_file
(
name
,
&
attr
,
&
module
,
&
size
,
&
info
,
0
,
0
,
current_machine
,
FALSE
);
status
=
open_builtin_pe_file
(
name
,
&
attr
,
&
module
,
&
size
,
&
info
,
0
,
0
,
current_machine
,
FALSE
);
if
(
status
==
STATUS_DLL_NOT_FOUND
)
if
(
status
==
STATUS_DLL_NOT_FOUND
)
{
{
sprintf
(
name
,
"%s/ntdll.dll.so"
,
ntdll_dir
);
free
(
name
);
asprintf
(
&
name
,
"%s/ntdll.dll.so"
,
ntdll_dir
);
status
=
open_builtin_so_file
(
name
,
&
attr
,
&
module
,
&
info
,
FALSE
);
status
=
open_builtin_so_file
(
name
,
&
attr
,
&
module
,
&
info
,
FALSE
);
}
}
if
(
status
==
STATUS_IMAGE_NOT_AT_BASE
)
status
=
virtual_relocate_module
(
module
);
if
(
status
==
STATUS_IMAGE_NOT_AT_BASE
)
status
=
virtual_relocate_module
(
module
);
...
@@ -1873,16 +1871,15 @@ static void load_apiset_dll(void)
...
@@ -1873,16 +1871,15 @@ static void load_apiset_dll(void)
unsigned
int
status
;
unsigned
int
status
;
HANDLE
handle
,
mapping
;
HANDLE
handle
,
mapping
;
SIZE_T
size
;
SIZE_T
size
;
char
*
name
;
char
*
name
=
NULL
;
void
*
ptr
;
void
*
ptr
;
UINT
i
;
UINT
i
;
init_unicode_string
(
&
str
,
path
);
init_unicode_string
(
&
str
,
path
);
InitializeObjectAttributes
(
&
attr
,
&
str
,
0
,
0
,
NULL
);
InitializeObjectAttributes
(
&
attr
,
&
str
,
0
,
0
,
NULL
);
name
=
malloc
(
strlen
(
ntdll_dir
)
+
strlen
(
pe_dir
)
+
sizeof
(
"/apisetschema/apisetschema.dll"
)
);
if
(
build_dir
)
asprintf
(
&
name
,
"%s/dlls/apisetschema%s/apisetschema.dll"
,
build_dir
,
pe_dir
);
if
(
build_dir
)
sprintf
(
name
,
"%s/dlls/apisetschema%s/apisetschema.dll"
,
build_dir
,
pe_dir
);
else
asprintf
(
&
name
,
"%s%s/apisetschema.dll"
,
dll_dir
,
pe_dir
);
else
sprintf
(
name
,
"%s%s/apisetschema.dll"
,
dll_dir
,
pe_dir
);
status
=
open_unix_file
(
&
handle
,
name
,
GENERIC_READ
|
SYNCHRONIZE
,
&
attr
,
0
,
status
=
open_unix_file
(
&
handle
,
name
,
GENERIC_READ
|
SYNCHRONIZE
,
&
attr
,
0
,
FILE_SHARE_READ
|
FILE_SHARE_DELETE
,
FILE_OPEN
,
FILE_SHARE_READ
|
FILE_SHARE_DELETE
,
FILE_OPEN
,
FILE_SYNCHRONOUS_IO_NONALERT
|
FILE_NON_DIRECTORY_FILE
,
NULL
,
0
);
FILE_SYNCHRONOUS_IO_NONALERT
|
FILE_NON_DIRECTORY_FILE
,
NULL
,
0
);
...
...
dlls/ntdll/unix/server.c
View file @
cd763004
...
@@ -1243,29 +1243,25 @@ int server_pipe( int fd[2] )
...
@@ -1243,29 +1243,25 @@ int server_pipe( int fd[2] )
*/
*/
static
const
char
*
init_server_dir
(
dev_t
dev
,
ino_t
ino
)
static
const
char
*
init_server_dir
(
dev_t
dev
,
ino_t
ino
)
{
{
char
*
p
,
*
dir
;
char
*
dir
=
NULL
;
size_t
len
=
sizeof
(
"/server-"
)
+
2
*
sizeof
(
dev
)
+
2
*
sizeof
(
ino
)
+
2
;
int
p
;
char
tmp
[
2
*
sizeof
(
dev
)
+
2
*
sizeof
(
ino
)
+
2
];
#ifdef __ANDROID__
/* there's no /tmp dir on Android */
len
+=
strlen
(
config_dir
)
+
sizeof
(
"/.wineserver"
);
dir
=
malloc
(
len
);
strcpy
(
dir
,
config_dir
);
strcat
(
dir
,
"/.wineserver/server-"
);
#else
len
+=
sizeof
(
"/tmp/.wine-"
)
+
12
;
dir
=
malloc
(
len
);
sprintf
(
dir
,
"/tmp/.wine-%u/server-"
,
getuid
()
);
#endif
p
=
dir
+
strlen
(
dir
);
if
(
dev
!=
(
unsigned
long
)
dev
)
if
(
dev
!=
(
unsigned
long
)
dev
)
p
+=
sprintf
(
p
,
"%lx%08lx-"
,
(
unsigned
long
)((
unsigned
long
long
)
dev
>>
32
),
(
unsigned
long
)
dev
);
p
=
snprintf
(
tmp
,
sizeof
(
tmp
)
,
"%lx%08lx-"
,
(
unsigned
long
)((
unsigned
long
long
)
dev
>>
32
),
(
unsigned
long
)
dev
);
else
else
p
+=
sprintf
(
p
,
"%lx-"
,
(
unsigned
long
)
dev
);
p
=
snprintf
(
tmp
,
sizeof
(
tmp
)
,
"%lx-"
,
(
unsigned
long
)
dev
);
if
(
ino
!=
(
unsigned
long
)
ino
)
if
(
ino
!=
(
unsigned
long
)
ino
)
s
printf
(
p
,
"%lx%08lx"
,
(
unsigned
long
)((
unsigned
long
long
)
ino
>>
32
),
(
unsigned
long
)
ino
);
s
nprintf
(
tmp
+
p
,
sizeof
(
tmp
)
-
p
,
"%lx%08lx"
,
(
unsigned
long
)((
unsigned
long
long
)
ino
>>
32
),
(
unsigned
long
)
ino
);
else
else
sprintf
(
p
,
"%lx"
,
(
unsigned
long
)
ino
);
snprintf
(
tmp
+
p
,
sizeof
(
tmp
)
-
p
,
"%lx"
,
(
unsigned
long
)
ino
);
#ifdef __ANDROID__
/* there's no /tmp dir on Android */
asprintf
(
&
dir
,
"%s/.wineserver/server-%s"
,
config_dir
,
tmp
);
#else
asprintf
(
&
dir
,
"/tmp/.wine-%u/server-%s"
,
getuid
(),
tmp
);
#endif
return
dir
;
return
dir
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment