Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
4d2972c8
Commit
4d2972c8
authored
15 years ago
by
Juan Lang
Committed by
Alexandre Julliard
15 years ago
Browse files
Options
Downloads
Patches
Plain Diff
crypt32: Use a helper function to simplify CertGetNameStringW.
parent
7d831064
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/crypt32/str.c
+52
-30
52 additions, 30 deletions
dlls/crypt32/str.c
with
52 additions
and
30 deletions
dlls/crypt32/str.c
+
52
−
30
View file @
4d2972c8
...
@@ -930,6 +930,42 @@ DWORD WINAPI CertGetNameStringA(PCCERT_CONTEXT pCertContext, DWORD dwType,
...
@@ -930,6 +930,42 @@ DWORD WINAPI CertGetNameStringA(PCCERT_CONTEXT pCertContext, DWORD dwType,
return
ret
;
return
ret
;
}
}
/* Searches cert's extensions for the alternate name extension with OID
* altNameOID, and if found, searches it for the alternate name type entryType.
* If found, returns a pointer to the entry, otherwise returns NULL.
* Regardless of whether an entry of the desired type is found, if the
* alternate name extension is present, sets *info to the decoded alternate
* name extension, which you must free using LocalFree.
* The return value is a pointer within *info, so don't free *info before
* you're done with the return value.
*/
static
PCERT_ALT_NAME_ENTRY
cert_find_alt_name_entry
(
PCCERT_CONTEXT
cert
,
LPCSTR
altNameOID
,
DWORD
entryType
,
PCERT_ALT_NAME_INFO
*
info
)
{
PCERT_ALT_NAME_ENTRY
entry
=
NULL
;
PCERT_EXTENSION
ext
=
CertFindExtension
(
altNameOID
,
cert
->
pCertInfo
->
cExtension
,
cert
->
pCertInfo
->
rgExtension
);
if
(
ext
)
{
DWORD
bytes
=
0
;
if
(
CryptDecodeObjectEx
(
cert
->
dwCertEncodingType
,
X509_ALTERNATE_NAME
,
ext
->
Value
.
pbData
,
ext
->
Value
.
cbData
,
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
info
,
&
bytes
))
{
DWORD
i
;
for
(
i
=
0
;
!
entry
&&
i
<
(
*
info
)
->
cAltEntry
;
i
++
)
if
((
*
info
)
->
rgAltEntry
[
i
].
dwAltNameChoice
==
entryType
)
entry
=
&
(
*
info
)
->
rgAltEntry
[
i
];
}
}
else
*
info
=
NULL
;
return
entry
;
}
DWORD
WINAPI
CertGetNameStringW
(
PCCERT_CONTEXT
pCertContext
,
DWORD
dwType
,
DWORD
WINAPI
CertGetNameStringW
(
PCCERT_CONTEXT
pCertContext
,
DWORD
dwType
,
DWORD
dwFlags
,
void
*
pvTypePara
,
LPWSTR
pszNameString
,
DWORD
cchNameString
)
DWORD
dwFlags
,
void
*
pvTypePara
,
LPWSTR
pszNameString
,
DWORD
cchNameString
)
{
{
...
@@ -975,42 +1011,28 @@ DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType,
...
@@ -975,42 +1011,28 @@ DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType,
pszNameString
,
cchNameString
);
pszNameString
,
cchNameString
);
else
else
{
{
P
CERT_
EXTENSION
ext
=
CertFindExtension
(
altNameOID
,
CERT_
ALT_NAME_INFO
*
altInfo
;
pCertContext
->
pCertInfo
->
cExtension
,
PCERT_ALT_NAME_ENTRY
entry
=
cert_find_alt_name_entry
(
pCertContext
,
pCertContext
->
pCertInfo
->
rgExtension
);
altNameOID
,
CERT_ALT_NAME_RFC822_NAME
,
&
altInfo
);
if
(
ext
)
if
(
altInfo
)
{
{
PCERT_ALT_NAME_INFO
altInfo
;
if
(
!
entry
&&
altInfo
->
cAltEntry
)
entry
=
&
altInfo
->
rgAltEntry
[
0
];
bytes
=
0
;
if
(
entry
)
if
(
CryptDecodeObjectEx
(
pCertContext
->
dwCertEncodingType
,
X509_ALTERNATE_NAME
,
ext
->
Value
.
pbData
,
ext
->
Value
.
cbData
,
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
&
altInfo
,
&
bytes
))
{
{
PCERT_ALT_NAME_ENTRY
entry
=
NULL
;
if
(
!
pszNameString
)
ret
=
strlenW
(
entry
->
pwszRfc822Name
)
+
1
;
for
(
i
=
0
;
!
entry
&&
i
<
altInfo
->
cAltEntry
;
i
++
)
else
if
(
altInfo
->
rgAltEntry
[
i
].
dwAltNameChoice
==
CERT_ALT_NAME_RFC822_NAME
)
entry
=
&
altInfo
->
rgAltEntry
[
i
];
if
(
!
entry
&&
altInfo
->
cAltEntry
)
entry
=
&
altInfo
->
rgAltEntry
[
0
];
if
(
entry
)
{
{
if
(
!
pszNameString
)
ret
=
min
(
strlenW
(
entry
->
pwszRfc822Name
),
ret
=
strlenW
(
entry
->
pwszRfc822Name
)
+
1
;
cchNameString
-
1
);
else
memcpy
(
pszNameString
,
entry
->
pwszRfc822Name
,
{
ret
*
sizeof
(
WCHAR
));
ret
=
min
(
strlenW
(
entry
->
pwszRfc822Name
),
pszNameString
[
ret
++
]
=
0
;
cchNameString
-
1
);
memcpy
(
pszNameString
,
entry
->
pwszRfc822Name
,
ret
*
sizeof
(
WCHAR
));
pszNameString
[
ret
++
]
=
0
;
}
}
}
LocalFree
(
altInfo
);
}
}
LocalFree
(
altInfo
);
}
}
}
}
if
(
nameInfo
)
if
(
nameInfo
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment