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
bc96cfac
Commit
bc96cfac
authored
Apr 14, 2022
by
Paul Gofman
Committed by
Alexandre Julliard
May 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Fix filling short output in CertGetNameStringA().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
66d9250c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
36 deletions
+32
-36
str.c
dlls/crypt32/str.c
+26
-34
str.c
dlls/crypt32/tests/str.c
+6
-2
No files found.
dlls/crypt32/str.c
View file @
bc96cfac
...
...
@@ -1110,46 +1110,38 @@ BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500,
return
ret
;
}
DWORD
WINAPI
CertGetNameStringA
(
PCCERT_CONTEXT
pCertContext
,
DWORD
dwT
ype
,
DWORD
dwFlags
,
void
*
pvTypePara
,
LPSTR
pszNameString
,
DWORD
cchNameString
)
DWORD
WINAPI
CertGetNameStringA
(
PCCERT_CONTEXT
cert
,
DWORD
t
ype
,
DWORD
flags
,
void
*
type_para
,
LPSTR
name
,
DWORD
name_len
)
{
DWORD
ret
;
DWORD
len
,
len_mb
,
ret
;
LPWSTR
nameW
;
TRACE
(
"(%p, %ld, %08lx, %p, %p, %ld)
\n
"
,
pCertContext
,
dwType
,
dwFlags
,
pvTypePara
,
pszNameString
,
cchNameString
);
TRACE
(
"(%p, %ld, %08lx, %p, %p, %ld)
\n
"
,
cert
,
type
,
flags
,
type_para
,
name
,
name_len
);
if
(
pszNameString
)
len
=
CertGetNameStringW
(
cert
,
type
,
flags
,
type_para
,
NULL
,
0
);
if
(
!
(
nameW
=
CryptMemAlloc
(
len
*
sizeof
(
*
nameW
))))
{
LPWSTR
wideName
;
DWORD
nameLen
;
ERR
(
"No memory.
\n
"
);
if
(
name
&&
name_len
)
*
name
=
0
;
return
1
;
}
nameLen
=
CertGetNameStringW
(
pCertContext
,
dwType
,
dwFlags
,
pvTypePara
,
NULL
,
0
);
wideName
=
CryptMemAlloc
(
nameLen
*
sizeof
(
WCHAR
));
if
(
wideName
)
{
CertGetNameStringW
(
pCertContext
,
dwType
,
dwFlags
,
pvTypePara
,
wideName
,
nameLen
);
nameLen
=
WideCharToMultiByte
(
CP_ACP
,
0
,
wideName
,
nameLen
,
pszNameString
,
cchNameString
,
NULL
,
NULL
);
if
(
nameLen
<=
cchNameString
)
ret
=
nameLen
;
else
{
pszNameString
[
cchNameString
-
1
]
=
'\0'
;
ret
=
cchNameString
;
}
CryptMemFree
(
wideName
);
}
else
{
*
pszNameString
=
'\0'
;
ret
=
1
;
}
len
=
CertGetNameStringW
(
cert
,
type
,
flags
,
type_para
,
nameW
,
len
);
len_mb
=
WideCharToMultiByte
(
CP_ACP
,
0
,
nameW
,
len
,
NULL
,
0
,
NULL
,
NULL
);
if
(
!
name
||
!
name_len
)
{
CryptMemFree
(
nameW
);
return
len_mb
;
}
else
ret
=
CertGetNameStringW
(
pCertContext
,
dwType
,
dwFlags
,
pvTypePara
,
NULL
,
0
);
ret
=
WideCharToMultiByte
(
CP_ACP
,
0
,
nameW
,
len
,
name
,
name_len
,
NULL
,
NULL
);
if
(
ret
<
len_mb
)
{
name
[
0
]
=
0
;
ret
=
1
;
}
CryptMemFree
(
nameW
);
return
ret
;
}
...
...
dlls/crypt32/tests/str.c
View file @
bc96cfac
...
...
@@ -766,9 +766,13 @@ static void test_CertGetNameString_value_(unsigned int line, PCCERT_CONTEXT cont
ok
(
!
strcmp
(
str
,
expected
),
"line %u: unexpected value %s.
\n
"
,
line
,
str
);
str
[
0
]
=
str
[
1
]
=
0xcc
;
retlen
=
CertGetNameStringA
(
context
,
type
,
0
,
type_para
,
str
,
len
-
1
);
todo_wine
ok
(
retlen
==
1
,
"line %u: Unexpected len %lu, expected 1.
\n
"
,
line
,
retlen
);
todo_wine
ok
(
!
str
[
0
],
"line %u: unexpected str[0] %#x.
\n
"
,
line
,
str
[
0
]);
ok
(
retlen
==
1
,
"line %u: Unexpected len %lu, expected 1.
\n
"
,
line
,
retlen
);
ok
(
!
str
[
0
],
"line %u: unexpected str[0] %#x.
\n
"
,
line
,
str
[
0
]);
ok
(
str
[
1
]
==
expected
[
1
],
"line %u: unexpected str[1] %#x.
\n
"
,
line
,
str
[
1
]);
retlen
=
CertGetNameStringA
(
context
,
type
,
0
,
type_para
,
str
,
0
);
ok
(
retlen
==
len
,
"line %u: Unexpected len %lu, expected 1.
\n
"
,
line
,
retlen
);
retlen
=
CertGetNameStringW
(
context
,
type
,
0
,
type_para
,
strW
,
len
);
ok
(
retlen
==
len
,
"line %u: unexpected len %lu, expected 1.
\n
"
,
line
,
retlen
);
ok
(
!
wcscmp
(
strW
,
expectedW
),
"line %u: unexpected value %s.
\n
"
,
line
,
debugstr_w
(
strW
));
...
...
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