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
c23865d9
Commit
c23865d9
authored
Feb 16, 2023
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Oct 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Add support for CERT_NAME_STR_NO_QUOTING_FLAG to CertNameToStr().
Signed-off-by:
Dmitry Timoshkov
<
dmitry@baikal.ru
>
parent
1252426d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
29 deletions
+34
-29
str.c
dlls/crypt32/str.c
+34
-27
str.c
dlls/crypt32/tests/str.c
+0
-2
No files found.
dlls/crypt32/str.c
View file @
c23865d9
...
@@ -144,8 +144,8 @@ static inline BOOL is_spaceW(WCHAR c)
...
@@ -144,8 +144,8 @@ static inline BOOL is_spaceW(WCHAR c)
return
c
<=
0x7f
&&
isspace
((
char
)
c
);
return
c
<=
0x7f
&&
isspace
((
char
)
c
);
}
}
static
DWORD
quote_rdn_value_to_str_w
(
DWORD
dwValueType
,
static
DWORD
quote_rdn_value_to_str_w
(
DWORD
dwValueType
,
PCERT_RDN_VALUE_BLOB
pValue
,
PCERT_RDN_VALUE_BLOB
pValu
e
,
LPWSTR
psz
,
DWORD
csz
)
DWORD
dwStrTyp
e
,
LPWSTR
psz
,
DWORD
csz
)
{
{
DWORD
ret
=
0
,
len
,
i
,
strLen
;
DWORD
ret
=
0
,
len
,
i
,
strLen
;
BOOL
needsQuotes
=
FALSE
;
BOOL
needsQuotes
=
FALSE
;
...
@@ -165,19 +165,22 @@ static DWORD quote_rdn_value_to_str_w(DWORD dwValueType,
...
@@ -165,19 +165,22 @@ static DWORD quote_rdn_value_to_str_w(DWORD dwValueType,
case
CERT_RDN_VISIBLE_STRING
:
case
CERT_RDN_VISIBLE_STRING
:
case
CERT_RDN_GENERAL_STRING
:
case
CERT_RDN_GENERAL_STRING
:
len
=
pValue
->
cbData
;
len
=
pValue
->
cbData
;
if
(
pValue
->
cbData
&&
isspace
(
pValue
->
pbData
[
0
]))
if
(
!
(
dwStrType
&
CERT_NAME_STR_NO_QUOTING_FLAG
))
needsQuotes
=
TRUE
;
if
(
pValue
->
cbData
&&
isspace
(
pValue
->
pbData
[
pValue
->
cbData
-
1
]))
needsQuotes
=
TRUE
;
for
(
i
=
0
;
i
<
pValue
->
cbData
;
i
++
)
{
{
if
(
is_quotable_char
(
pValue
->
pbData
[
i
]))
if
(
pValue
->
cbData
&&
isspace
(
pValue
->
pbData
[
0
]))
needsQuotes
=
TRUE
;
needsQuotes
=
TRUE
;
if
(
pValue
->
pbData
[
i
]
==
'"'
)
if
(
pValue
->
cbData
&&
isspace
(
pValue
->
pbData
[
pValue
->
cbData
-
1
]))
len
+=
1
;
needsQuotes
=
TRUE
;
for
(
i
=
0
;
i
<
pValue
->
cbData
;
i
++
)
{
if
(
is_quotable_char
(
pValue
->
pbData
[
i
]))
needsQuotes
=
TRUE
;
if
(
pValue
->
pbData
[
i
]
==
'"'
)
len
+=
1
;
}
if
(
needsQuotes
)
len
+=
2
;
}
}
if
(
needsQuotes
)
len
+=
2
;
if
(
!
psz
||
!
csz
)
if
(
!
psz
||
!
csz
)
ret
=
len
;
ret
=
len
;
else
else
...
@@ -189,7 +192,8 @@ static DWORD quote_rdn_value_to_str_w(DWORD dwValueType,
...
@@ -189,7 +192,8 @@ static DWORD quote_rdn_value_to_str_w(DWORD dwValueType,
for
(
i
=
0
;
i
<
pValue
->
cbData
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
for
(
i
=
0
;
i
<
pValue
->
cbData
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
{
{
*
ptr
=
pValue
->
pbData
[
i
];
*
ptr
=
pValue
->
pbData
[
i
];
if
(
pValue
->
pbData
[
i
]
==
'"'
&&
ptr
-
psz
<
csz
-
1
)
if
(
!
(
dwStrType
&
CERT_NAME_STR_NO_QUOTING_FLAG
)
&&
pValue
->
pbData
[
i
]
==
'"'
&&
ptr
-
psz
<
csz
-
1
)
*
(
++
ptr
)
=
'"'
;
*
(
++
ptr
)
=
'"'
;
}
}
if
(
needsQuotes
&&
ptr
-
psz
<
csz
)
if
(
needsQuotes
&&
ptr
-
psz
<
csz
)
...
@@ -200,19 +204,22 @@ static DWORD quote_rdn_value_to_str_w(DWORD dwValueType,
...
@@ -200,19 +204,22 @@ static DWORD quote_rdn_value_to_str_w(DWORD dwValueType,
case
CERT_RDN_BMP_STRING
:
case
CERT_RDN_BMP_STRING
:
case
CERT_RDN_UTF8_STRING
:
case
CERT_RDN_UTF8_STRING
:
strLen
=
len
=
pValue
->
cbData
/
sizeof
(
WCHAR
);
strLen
=
len
=
pValue
->
cbData
/
sizeof
(
WCHAR
);
if
(
strLen
&&
is_spaceW
(((
LPCWSTR
)
pValue
->
pbData
)[
0
]))
if
(
!
(
dwStrType
&
CERT_NAME_STR_NO_QUOTING_FLAG
))
needsQuotes
=
TRUE
;
if
(
strLen
&&
_spaceW
(((
LPCWSTR
)
pValue
->
pbData
)[
strLen
-
1
]))
needsQuotes
=
TRUE
;
for
(
i
=
0
;
i
<
strLen
;
i
++
)
{
{
if
(
is_quotable_char
(((
LPCWSTR
)
pValue
->
pbData
)[
i
]))
if
(
strLen
&&
is_spaceW
(((
LPCWSTR
)
pValue
->
pbData
)[
0
]))
needsQuotes
=
TRUE
;
needsQuotes
=
TRUE
;
if
(((
LPCWSTR
)
pValue
->
pbData
)[
i
]
==
'"'
)
if
(
strLen
&&
is_spaceW
(((
LPCWSTR
)
pValue
->
pbData
)[
strLen
-
1
]))
len
+=
1
;
needsQuotes
=
TRUE
;
for
(
i
=
0
;
i
<
strLen
;
i
++
)
{
if
(
is_quotable_char
(((
LPCWSTR
)
pValue
->
pbData
)[
i
]))
needsQuotes
=
TRUE
;
if
(((
LPCWSTR
)
pValue
->
pbData
)[
i
]
==
'"'
)
len
+=
1
;
}
if
(
needsQuotes
)
len
+=
2
;
}
}
if
(
needsQuotes
)
len
+=
2
;
if
(
!
psz
||
!
csz
)
if
(
!
psz
||
!
csz
)
ret
=
len
;
ret
=
len
;
else
else
...
@@ -224,7 +231,8 @@ static DWORD quote_rdn_value_to_str_w(DWORD dwValueType,
...
@@ -224,7 +231,8 @@ static DWORD quote_rdn_value_to_str_w(DWORD dwValueType,
for
(
i
=
0
;
i
<
strLen
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
for
(
i
=
0
;
i
<
strLen
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
{
{
*
ptr
=
((
LPCWSTR
)
pValue
->
pbData
)[
i
];
*
ptr
=
((
LPCWSTR
)
pValue
->
pbData
)[
i
];
if
(((
LPCWSTR
)
pValue
->
pbData
)[
i
]
==
'"'
&&
ptr
-
psz
<
csz
-
1
)
if
(
!
(
dwStrType
&
CERT_NAME_STR_NO_QUOTING_FLAG
)
&&
((
LPCWSTR
)
pValue
->
pbData
)[
i
]
==
'"'
&&
ptr
-
psz
<
csz
-
1
)
*
(
++
ptr
)
=
'"'
;
*
(
++
ptr
)
=
'"'
;
}
}
if
(
needsQuotes
&&
ptr
-
psz
<
csz
)
if
(
needsQuotes
&&
ptr
-
psz
<
csz
)
...
@@ -328,8 +336,7 @@ static const WCHAR indent[] = L" ";
...
@@ -328,8 +336,7 @@ static const WCHAR indent[] = L" ";
DWORD
cert_name_to_str_with_indent
(
DWORD
dwCertEncodingType
,
DWORD
indentLevel
,
DWORD
cert_name_to_str_with_indent
(
DWORD
dwCertEncodingType
,
DWORD
indentLevel
,
const
CERT_NAME_BLOB
*
pName
,
DWORD
dwStrType
,
LPWSTR
psz
,
DWORD
csz
)
const
CERT_NAME_BLOB
*
pName
,
DWORD
dwStrType
,
LPWSTR
psz
,
DWORD
csz
)
{
{
static
const
DWORD
unsupportedFlags
=
CERT_NAME_STR_NO_QUOTING_FLAG
|
static
const
DWORD
unsupportedFlags
=
CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG
;
CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG
;
DWORD
ret
=
0
,
bytes
=
0
;
DWORD
ret
=
0
,
bytes
=
0
;
BOOL
bRet
;
BOOL
bRet
;
CERT_NAME_INFO
*
info
;
CERT_NAME_INFO
*
info
;
...
@@ -419,7 +426,7 @@ DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indentLevel,
...
@@ -419,7 +426,7 @@ DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indentLevel,
}
}
if
(
psz
&&
ret
+
1
==
csz
)
break
;
if
(
psz
&&
ret
+
1
==
csz
)
break
;
chars
=
quote_rdn_value_to_str_w
(
rdn
->
rgRDNAttr
[
j
].
dwValueType
,
&
rdn
->
rgRDNAttr
[
j
].
Value
,
chars
=
quote_rdn_value_to_str_w
(
rdn
->
rgRDNAttr
[
j
].
dwValueType
,
&
rdn
->
rgRDNAttr
[
j
].
Value
,
dwStrType
,
psz
?
psz
+
ret
:
NULL
,
psz
?
csz
-
ret
-
1
:
0
);
psz
?
psz
+
ret
:
NULL
,
psz
?
csz
-
ret
-
1
:
0
);
ret
+=
chars
;
ret
+=
chars
;
if
(
j
<
rdn
->
cRDNAttr
-
1
)
if
(
j
<
rdn
->
cRDNAttr
-
1
)
...
...
dlls/crypt32/tests/str.c
View file @
c23865d9
...
@@ -1163,7 +1163,6 @@ static void test_quoted_RDN(void)
...
@@ -1163,7 +1163,6 @@ static void test_quoted_RDN(void)
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_X500_NAME_STR
|
CERT_NAME_STR_NO_QUOTING_FLAG
,
str
,
ARRAY_SIZE
(
str
));
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_X500_NAME_STR
|
CERT_NAME_STR_NO_QUOTING_FLAG
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcsncmp
(
str
,
L"CN="
,
3
),
"got %s
\n
"
,
debugstr_w
(
str
));
ok
(
!
wcsncmp
(
str
,
L"CN="
,
3
),
"got %s
\n
"
,
debugstr_w
(
str
));
todo_wine_if
(
i
!=
0
&&
i
!=
13
&&
i
!=
14
)
ok
(
!
wcscmp
(
&
str
[
3
],
test
[
i
].
CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
3
]),
debugstr_w
(
test
[
i
].
CN
));
ok
(
!
wcscmp
(
&
str
[
3
],
test
[
i
].
CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
3
]),
debugstr_w
(
test
[
i
].
CN
));
LocalFree
(
buf
);
LocalFree
(
buf
);
...
@@ -1217,7 +1216,6 @@ static void test_quoted_RDN(void)
...
@@ -1217,7 +1216,6 @@ static void test_quoted_RDN(void)
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_X500_NAME_STR
|
CERT_NAME_STR_NO_QUOTING_FLAG
,
str
,
ARRAY_SIZE
(
str
));
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_X500_NAME_STR
|
CERT_NAME_STR_NO_QUOTING_FLAG
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcsncmp
(
str
,
L"CN="
,
3
),
"got %s
\n
"
,
debugstr_w
(
str
));
ok
(
!
wcsncmp
(
str
,
L"CN="
,
3
),
"got %s
\n
"
,
debugstr_w
(
str
));
todo_wine_if
(
i
!=
0
&&
i
!=
13
&&
i
!=
14
)
ok
(
!
wcscmp
(
&
str
[
3
],
test
[
i
].
CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
3
]),
debugstr_w
(
test
[
i
].
CN
));
ok
(
!
wcscmp
(
&
str
[
3
],
test
[
i
].
CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
3
]),
debugstr_w
(
test
[
i
].
CN
));
LocalFree
(
buf
);
LocalFree
(
buf
);
...
...
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