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
4e04b2d5
Commit
4e04b2d5
authored
Mar 19, 2024
by
Brendan Shanks
Committed by
Alexandre Julliard
Mar 28, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server: Replace some malloc/sprintf/strcpy calls with asprintf.
parent
d7cf25dc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
22 deletions
+12
-22
request.c
server/request.c
+10
-14
unicode.c
server/unicode.c
+2
-8
No files found.
server/request.c
View file @
4e04b2d5
...
@@ -601,9 +601,8 @@ static void create_dir( const char *name, struct stat *st )
...
@@ -601,9 +601,8 @@ static void create_dir( const char *name, struct stat *st )
static
char
*
create_server_dir
(
int
force
)
static
char
*
create_server_dir
(
int
force
)
{
{
const
char
*
prefix
=
getenv
(
"WINEPREFIX"
);
const
char
*
prefix
=
getenv
(
"WINEPREFIX"
);
char
*
p
,
*
config_dir
;
char
*
p
,
*
config_dir
,
*
base_dir
;
struct
stat
st
,
st2
;
struct
stat
st
,
st2
;
size_t
len
=
sizeof
(
"/server-"
)
+
2
*
sizeof
(
st
.
st_dev
)
+
2
*
sizeof
(
st
.
st_ino
)
+
2
;
/* open the configuration directory */
/* open the configuration directory */
...
@@ -646,23 +645,19 @@ static char *create_server_dir( int force )
...
@@ -646,23 +645,19 @@ static char *create_server_dir( int force )
/* create the base directory if needed */
/* create the base directory if needed */
#ifdef __ANDROID__
/* there's no /tmp dir on Android */
#ifdef __ANDROID__
/* there's no /tmp dir on Android */
len
+=
strlen
(
config_dir
)
+
sizeof
(
"/.wineserver"
);
if
(
asprintf
(
&
base_dir
,
"%s/.wineserver"
,
config_dir
)
==
-
1
)
if
(
!
(
server_dir
=
malloc
(
len
)))
fatal_error
(
"out of memory
\n
"
);
fatal_error
(
"out of memory
\n
"
);
strcpy
(
server_dir
,
config_dir
);
strcat
(
server_dir
,
"/.wineserver"
);
#else
#else
len
+=
sizeof
(
"/tmp/.wine-"
)
+
12
;
if
(
asprintf
(
&
base_dir
,
"/tmp/.wine-%u"
,
getuid
()
)
==
-
1
)
if
(
!
(
server_dir
=
malloc
(
len
)))
fatal_error
(
"out of memory
\n
"
);
fatal_error
(
"out of memory
\n
"
);
sprintf
(
server_dir
,
"/tmp/.wine-%u"
,
getuid
()
);
#endif
#endif
create_dir
(
server
_dir
,
&
st2
);
create_dir
(
base
_dir
,
&
st2
);
/* now create the server directory */
/* now create the server directory */
strcat
(
server_dir
,
"/server-"
);
if
(
asprintf
(
&
server_dir
,
"%s/server-%llx-%llx"
,
base_dir
,
p
=
server_dir
+
strlen
(
server_dir
);
(
unsigned
long
long
)
st
.
st_dev
,
(
unsigned
long
long
)
st
.
st_ino
)
==
-
1
)
fatal_error
(
"out of memory
\n
"
);
sprintf
(
p
,
"%llx-%llx"
,
(
unsigned
long
long
)
st
.
st_dev
,
(
unsigned
long
long
)
st
.
st_ino
);
create_dir
(
server_dir
,
&
st
);
create_dir
(
server_dir
,
&
st
);
...
@@ -675,6 +670,7 @@ static char *create_server_dir( int force )
...
@@ -675,6 +670,7 @@ static char *create_server_dir( int force )
if
(
st
.
st_dev
!=
st2
.
st_dev
||
st
.
st_ino
!=
st2
.
st_ino
)
if
(
st
.
st_dev
!=
st2
.
st_dev
||
st
.
st_ino
!=
st2
.
st_ino
)
fatal_error
(
"chdir did not end up in %s
\n
"
,
server_dir
);
fatal_error
(
"chdir did not end up in %s
\n
"
,
server_dir
);
free
(
base_dir
);
free
(
config_dir
);
free
(
config_dir
);
return
server_dir
;
return
server_dir
;
}
}
...
...
server/unicode.c
View file @
4e04b2d5
...
@@ -265,11 +265,7 @@ static char *get_nls_dir(void)
...
@@ -265,11 +265,7 @@ static char *get_nls_dir(void)
}
}
*
(
++
p
)
=
0
;
*
(
++
p
)
=
0
;
if
(
p
>
dir
+
8
&&
!
strcmp
(
p
-
8
,
"/server/"
))
nlsdir
=
"../nls"
;
/* inside build tree */
if
(
p
>
dir
+
8
&&
!
strcmp
(
p
-
8
,
"/server/"
))
nlsdir
=
"../nls"
;
/* inside build tree */
if
((
ret
=
malloc
(
strlen
(
dir
)
+
strlen
(
nlsdir
)
+
1
)))
asprintf
(
&
ret
,
"%s%s"
,
dir
,
nlsdir
);
{
strcpy
(
ret
,
dir
);
strcat
(
ret
,
nlsdir
);
}
free
(
dir
);
free
(
dir
);
return
ret
;
return
ret
;
}
}
...
@@ -292,9 +288,7 @@ struct fd *load_intl_file(void)
...
@@ -292,9 +288,7 @@ struct fd *load_intl_file(void)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
nls_dirs
);
i
++
)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
nls_dirs
);
i
++
)
{
{
if
(
!
nls_dirs
[
i
])
continue
;
if
(
!
nls_dirs
[
i
])
continue
;
if
(
!
(
path
=
malloc
(
strlen
(
nls_dirs
[
i
])
+
sizeof
(
"/l_intl.nls"
))))
continue
;
if
(
asprintf
(
&
path
,
"%s/l_intl.nls"
,
nls_dirs
[
i
]
)
==
-
1
)
continue
;
strcpy
(
path
,
nls_dirs
[
i
]
);
strcat
(
path
,
"/l_intl.nls"
);
if
((
fd
=
open_fd
(
NULL
,
path
,
nt_name
,
O_RDONLY
,
&
mode
,
FILE_READ_DATA
,
if
((
fd
=
open_fd
(
NULL
,
path
,
nt_name
,
O_RDONLY
,
&
mode
,
FILE_READ_DATA
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
,
FILE_NON_DIRECTORY_FILE
|
FILE_SYNCHRONOUS_IO_NONALERT
)))
break
;
FILE_NON_DIRECTORY_FILE
|
FILE_SYNCHRONOUS_IO_NONALERT
)))
break
;
...
...
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