Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
7aa67f1e
Commit
7aa67f1e
authored
Dec 01, 2017
by
Piotr Caban
Committed by
Alexandre Julliard
Dec 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Fix buffer size checks in swscanf_s.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
3561645a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
3 deletions
+37
-3
scanf.h
dlls/msvcrt/scanf.h
+3
-3
scanf.c
dlls/msvcrt/tests/scanf.c
+34
-0
No files found.
dlls/msvcrt/scanf.h
View file @
7aa67f1e
...
...
@@ -540,7 +540,7 @@ _FUNCTION_ {
char
*
str
=
suppress
?
NULL
:
va_arg
(
ap
,
char
*
);
char
*
pstr
=
str
;
#ifdef SECURE
unsigned
size
=
suppress
?
UINT_MAX
:
va_arg
(
ap
,
unsigned
)
/
sizeof
(
char
)
;
unsigned
size
=
suppress
?
UINT_MAX
:
va_arg
(
ap
,
unsigned
);
#else
unsigned
size
=
UINT_MAX
;
#endif
...
...
@@ -566,7 +566,7 @@ _FUNCTION_ {
MSVCRT_wchar_t
*
str
=
suppress
?
NULL
:
va_arg
(
ap
,
MSVCRT_wchar_t
*
);
MSVCRT_wchar_t
*
pstr
=
str
;
#ifdef SECURE
unsigned
size
=
suppress
?
UINT_MAX
:
va_arg
(
ap
,
unsigned
)
/
sizeof
(
MSVCRT_wchar_t
)
;
unsigned
size
=
suppress
?
UINT_MAX
:
va_arg
(
ap
,
unsigned
);
#else
unsigned
size
=
UINT_MAX
;
#endif
...
...
@@ -615,7 +615,7 @@ _FUNCTION_ {
ULONG
*
Mask
;
int
invert
=
0
;
/* Set if we are NOT to find the chars */
#ifdef SECURE
unsigned
size
=
suppress
?
UINT_MAX
:
va_arg
(
ap
,
unsigned
)
/
sizeof
(
_CHAR_
)
;
unsigned
size
=
suppress
?
UINT_MAX
:
va_arg
(
ap
,
unsigned
);
#else
unsigned
size
=
UINT_MAX
;
#endif
...
...
dlls/msvcrt/tests/scanf.c
View file @
7aa67f1e
...
...
@@ -324,9 +324,43 @@ static void test_swscanf( void )
ok
(
c
==
'b'
,
"c = %x
\n
"
,
c
);
}
static
void
test_swscanf_s
(
void
)
{
static
const
wchar_t
fmt1
[]
=
{
'%'
,
'c'
,
0
};
static
const
wchar_t
fmt2
[]
=
{
'%'
,
'['
,
'a'
,
'-'
,
'z'
,
']'
,
0
};
int
(
WINAPIV
*
pswscanf_s
)(
const
wchar_t
*
,
const
wchar_t
*
,...);
HMODULE
hmod
=
GetModuleHandleA
(
"msvcrt.dll"
);
wchar_t
buf
[
2
],
out
[
2
];
int
ret
;
pswscanf_s
=
(
void
*
)
GetProcAddress
(
hmod
,
"swscanf_s"
);
if
(
!
pswscanf_s
)
{
win_skip
(
"swscanf_s not available
\n
"
);
return
;
}
buf
[
0
]
=
'a'
;
buf
[
1
]
=
'1'
;
out
[
1
]
=
'b'
;
ret
=
pswscanf_s
(
buf
,
fmt1
,
out
,
1
);
ok
(
ret
==
1
,
"swscanf_s returned %d
\n
"
,
ret
);
ok
(
out
[
0
]
==
'a'
,
"out[0] = %x
\n
"
,
out
[
0
]);
ok
(
out
[
1
]
==
'b'
,
"out[1] = %x
\n
"
,
out
[
1
]);
ret
=
pswscanf_s
(
buf
,
fmt2
,
out
,
1
);
ok
(
!
ret
,
"swscanf_s returned %d
\n
"
,
ret
);
ret
=
pswscanf_s
(
buf
,
fmt2
,
out
,
2
);
ok
(
ret
==
1
,
"swscanf_s returned %d
\n
"
,
ret
);
ok
(
out
[
0
]
==
'a'
,
"out[0] = %x
\n
"
,
out
[
0
]);
ok
(
!
out
[
1
],
"out[1] = %x
\n
"
,
out
[
1
]);
}
START_TEST
(
scanf
)
{
test_sscanf
();
test_sscanf_s
();
test_swscanf
();
test_swscanf_s
();
}
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