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
dcafe721
Commit
dcafe721
authored
Oct 18, 2010
by
Juan Lang
Committed by
Alexandre Julliard
Oct 19, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Implement quoting of BMP strings.
parent
99306803
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
5 deletions
+46
-5
str.c
dlls/crypt32/str.c
+41
-0
str.c
dlls/crypt32/tests/str.c
+5
-5
No files found.
dlls/crypt32/str.c
View file @
dcafe721
...
...
@@ -100,6 +100,46 @@ DWORD WINAPI CertRDNValueToStrA(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
ret
=
ptr
-
psz
;
}
break
;
case
CERT_RDN_BMP_STRING
:
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
LPCWSTR
)
pValue
->
pbData
,
pValue
->
cbData
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
if
(
pValue
->
cbData
&&
isspaceW
(((
LPCWSTR
)
pValue
->
pbData
)[
0
]))
needsQuotes
=
TRUE
;
if
(
pValue
->
cbData
&&
isspaceW
(((
LPCWSTR
)
pValue
->
pbData
)[
pValue
->
cbData
/
sizeof
(
WCHAR
)
-
1
]))
needsQuotes
=
TRUE
;
for
(
i
=
0
;
i
<
pValue
->
cbData
/
sizeof
(
WCHAR
);
i
++
)
{
if
(
is_quotable_char
(((
LPCWSTR
)
pValue
->
pbData
)[
i
]))
needsQuotes
=
TRUE
;
if
(((
LPCWSTR
)
pValue
->
pbData
)[
i
]
==
'"'
)
len
+=
1
;
}
if
(
needsQuotes
)
len
+=
2
;
if
(
!
psz
||
!
csz
)
ret
=
len
;
else
{
char
*
dst
=
psz
;
if
(
needsQuotes
)
*
dst
++
=
'"'
;
for
(
i
=
0
;
i
<
pValue
->
cbData
/
sizeof
(
WCHAR
)
&&
dst
-
psz
<
csz
;
dst
++
,
i
++
)
{
LPCWSTR
src
=
(
LPCWSTR
)
pValue
->
pbData
+
i
;
WideCharToMultiByte
(
CP_ACP
,
0
,
src
,
1
,
dst
,
csz
-
(
dst
-
psz
)
-
1
,
NULL
,
NULL
);
if
(
*
src
==
'"'
&&
dst
-
psz
<
csz
-
1
)
*
(
++
dst
)
=
'"'
;
}
if
(
needsQuotes
&&
dst
-
psz
<
csz
)
*
dst
++
=
'"'
;
ret
=
dst
-
psz
;
}
break
;
case
CERT_RDN_UTF8_STRING
:
if
(
!
psz
||
!
csz
)
ret
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
(
LPWSTR
)
pValue
->
pbData
,
...
...
@@ -146,6 +186,7 @@ DWORD WINAPI CertRDNValueToStrW(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
case
CERT_RDN_GRAPHIC_STRING
:
case
CERT_RDN_VISIBLE_STRING
:
case
CERT_RDN_GENERAL_STRING
:
case
CERT_RDN_BMP_STRING
:
len
=
pValue
->
cbData
;
if
(
pValue
->
cbData
&&
isspace
(
pValue
->
pbData
[
0
]))
needsQuotes
=
TRUE
;
...
...
dlls/crypt32/tests/str.c
View file @
dcafe721
...
...
@@ -443,7 +443,7 @@ static void test_CertNameToStrA(void)
blob
.
pbData
=
encodedQuotedCN
;
blob
.
cbData
=
sizeof
(
encodedQuotedCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"\"\"
1
\"\"\"
"
,
TRU
E
);
FALS
E
);
blob
.
pbData
=
encodedMultipleAttrCN
;
blob
.
cbData
=
sizeof
(
encodedMultipleAttrCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
1+2
\"
"
,
FALSE
);
...
...
@@ -455,16 +455,16 @@ static void test_CertNameToStrA(void)
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
a=b
\"
"
,
FALSE
);
blob
.
pbData
=
encodedLessThanCN
;
blob
.
cbData
=
sizeof
(
encodedLessThanCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
<
\"
"
,
TRU
E
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
<
\"
"
,
FALS
E
);
blob
.
pbData
=
encodedGreaterThanCN
;
blob
.
cbData
=
sizeof
(
encodedGreaterThanCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
>
\"
"
,
TRU
E
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
>
\"
"
,
FALS
E
);
blob
.
pbData
=
encodedHashCN
;
blob
.
cbData
=
sizeof
(
encodedHashCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
#
\"
"
,
TRU
E
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
#
\"
"
,
FALS
E
);
blob
.
pbData
=
encodedSemiCN
;
blob
.
cbData
=
sizeof
(
encodedSemiCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
;
\"
"
,
TRU
E
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
;
\"
"
,
FALS
E
);
}
static
void
test_NameToStrConversionW
(
PCERT_NAME_BLOB
pName
,
DWORD
dwStrType
,
...
...
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