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
b350095b
Commit
b350095b
authored
Jul 03, 2019
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Move null terminating result to pf_vsnprintf callers.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
51bc180c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
10 deletions
+38
-10
printf.c
dlls/ntdll/printf.c
+38
-10
No files found.
dlls/ntdll/printf.c
View file @
b350095b
...
...
@@ -75,17 +75,23 @@ static inline int pf_output_stringW( pf_output *out, LPCWSTR str, int len )
if
(
out
->
unicode
)
{
LPWSTR
p
=
out
->
buf
.
W
+
out
->
used
;
out
->
used
+=
len
;
if
(
!
out
->
buf
.
W
)
{
out
->
used
+=
len
;
return
len
;
}
if
(
space
>=
len
)
{
memcpy
(
p
,
str
,
len
*
sizeof
(
WCHAR
)
);
out
->
used
+=
len
;
return
len
;
}
if
(
space
>
0
)
{
memcpy
(
p
,
str
,
space
*
sizeof
(
WCHAR
)
);
out
->
used
+=
space
;
}
}
else
{
...
...
@@ -93,16 +99,23 @@ static inline int pf_output_stringW( pf_output *out, LPCWSTR str, int len )
ULONG
n
;
RtlUnicodeToMultiByteSize
(
&
n
,
str
,
len
*
sizeof
(
WCHAR
)
);
out
->
used
+=
n
;
if
(
!
out
->
buf
.
A
)
{
out
->
used
+=
n
;
return
len
;
}
if
(
space
>=
n
)
{
RtlUnicodeToMultiByteN
(
p
,
n
,
NULL
,
str
,
len
*
sizeof
(
WCHAR
)
);
out
->
used
+=
n
;
return
len
;
}
if
(
space
>
0
)
RtlUnicodeToMultiByteN
(
p
,
space
,
NULL
,
str
,
len
*
sizeof
(
WCHAR
)
);
if
(
space
>
0
)
{
RtlUnicodeToMultiByteN
(
p
,
space
,
NULL
,
str
,
len
*
sizeof
(
WCHAR
)
);
out
->
used
+=
space
;
}
}
return
-
1
;
}
...
...
@@ -116,17 +129,23 @@ static inline int pf_output_stringA( pf_output *out, LPCSTR str, int len )
if
(
!
out
->
unicode
)
{
LPSTR
p
=
out
->
buf
.
A
+
out
->
used
;
out
->
used
+=
len
;
if
(
!
out
->
buf
.
A
)
{
out
->
used
+=
len
;
return
len
;
}
if
(
space
>=
len
)
{
memcpy
(
p
,
str
,
len
);
out
->
used
+=
len
;
return
len
;
}
if
(
space
>
0
)
{
memcpy
(
p
,
str
,
space
);
out
->
used
+=
space
;
}
}
else
{
...
...
@@ -134,16 +153,23 @@ static inline int pf_output_stringA( pf_output *out, LPCSTR str, int len )
ULONG
n
;
RtlMultiByteToUnicodeSize
(
&
n
,
str
,
len
);
out
->
used
+=
n
/
sizeof
(
WCHAR
);
if
(
!
out
->
buf
.
W
)
{
out
->
used
+=
n
/
sizeof
(
WCHAR
);
return
len
;
}
if
(
space
>=
n
/
sizeof
(
WCHAR
))
{
RtlMultiByteToUnicodeN
(
p
,
n
,
NULL
,
str
,
len
);
out
->
used
+=
n
/
sizeof
(
WCHAR
);
return
len
;
}
if
(
space
>
0
)
RtlMultiByteToUnicodeN
(
p
,
space
*
sizeof
(
WCHAR
),
NULL
,
str
,
len
);
if
(
space
>
0
)
{
RtlMultiByteToUnicodeN
(
p
,
space
*
sizeof
(
WCHAR
),
NULL
,
str
,
len
);
out
->
used
+=
space
;
}
}
return
-
1
;
}
...
...
@@ -657,9 +683,7 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
/* check we reached the end, and null terminate the string */
assert
(
*
p
==
0
);
pf_output_stringW
(
out
,
p
,
1
);
return
out
->
used
-
1
;
return
out
->
used
;
}
...
...
@@ -686,6 +710,7 @@ int CDECL NTDLL__vsnprintf( char *str, SIZE_T len, const char *format, __ms_va_l
}
r
=
pf_vsnprintf
(
&
out
,
formatW
,
args
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
formatW
);
if
(
out
.
used
<
len
)
str
[
out
.
used
]
=
0
;
return
r
;
}
...
...
@@ -696,13 +721,16 @@ int CDECL NTDLL__vsnprintf( char *str, SIZE_T len, const char *format, __ms_va_l
int
CDECL
NTDLL__vsnwprintf
(
WCHAR
*
str
,
SIZE_T
len
,
const
WCHAR
*
format
,
__ms_va_list
args
)
{
pf_output
out
;
int
r
;
out
.
unicode
=
TRUE
;
out
.
buf
.
W
=
str
;
out
.
used
=
0
;
out
.
len
=
len
;
return
pf_vsnprintf
(
&
out
,
format
,
args
);
r
=
pf_vsnprintf
(
&
out
,
format
,
args
);
if
(
out
.
used
<
len
)
str
[
out
.
used
]
=
0
;
return
r
;
}
...
...
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