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
99306803
Commit
99306803
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 simple string types.
parent
462af2f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
21 deletions
+76
-21
str.c
dlls/crypt32/str.c
+72
-17
str.c
dlls/crypt32/tests/str.c
+4
-4
No files found.
dlls/crypt32/str.c
View file @
99306803
...
...
@@ -29,10 +29,29 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
crypt
);
static
inline
BOOL
is_quotable_char
(
char
c
)
{
switch
(
c
)
{
case
'+'
:
case
','
:
case
'"'
:
case
'='
:
case
'<'
:
case
'>'
:
case
';'
:
case
'#'
:
return
TRUE
;
default:
return
FALSE
;
}
}
DWORD
WINAPI
CertRDNValueToStrA
(
DWORD
dwValueType
,
PCERT_RDN_VALUE_BLOB
pValue
,
LPSTR
psz
,
DWORD
csz
)
{
DWORD
ret
=
0
;
DWORD
ret
=
0
,
len
,
i
;
BOOL
needsQuotes
=
FALSE
;
TRACE
(
"(%d, %p, %p, %d)
\n
"
,
dwValueType
,
pValue
,
psz
,
csz
);
...
...
@@ -48,18 +67,37 @@ DWORD WINAPI CertRDNValueToStrA(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
case
CERT_RDN_GRAPHIC_STRING
:
case
CERT_RDN_VISIBLE_STRING
:
case
CERT_RDN_GENERAL_STRING
:
len
=
pValue
->
cbData
;
if
(
pValue
->
cbData
&&
isspace
(
pValue
->
pbData
[
0
]))
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
]))
needsQuotes
=
TRUE
;
if
(
pValue
->
pbData
[
i
]
==
'"'
)
len
+=
1
;
}
if
(
needsQuotes
)
len
+=
2
;
if
(
!
psz
||
!
csz
)
ret
=
pValue
->
cbData
;
ret
=
len
;
else
{
DWORD
chars
=
min
(
pValue
->
cbData
,
csz
-
1
)
;
char
*
ptr
=
psz
;
if
(
chars
)
if
(
needsQuotes
)
*
ptr
++
=
'"'
;
for
(
i
=
0
;
i
<
pValue
->
cbData
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
{
memcpy
(
psz
,
pValue
->
pbData
,
chars
)
;
ret
+=
chars
;
csz
-=
chars
;
*
ptr
=
pValue
->
pbData
[
i
]
;
if
(
pValue
->
pbData
[
i
]
==
'"'
&&
ptr
-
psz
<
csz
-
1
)
*
(
++
ptr
)
=
'"'
;
}
if
(
needsQuotes
&&
ptr
-
psz
<
csz
)
*
ptr
++
=
'"'
;
ret
=
ptr
-
psz
;
}
break
;
case
CERT_RDN_UTF8_STRING
:
...
...
@@ -91,7 +129,8 @@ DWORD WINAPI CertRDNValueToStrA(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
DWORD
WINAPI
CertRDNValueToStrW
(
DWORD
dwValueType
,
PCERT_RDN_VALUE_BLOB
pValue
,
LPWSTR
psz
,
DWORD
csz
)
{
DWORD
ret
=
0
;
DWORD
ret
=
0
,
len
,
i
;
BOOL
needsQuotes
=
FALSE
;
TRACE
(
"(%d, %p, %p, %d)
\n
"
,
dwValueType
,
pValue
,
psz
,
csz
);
...
...
@@ -107,21 +146,37 @@ 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
:
len
=
pValue
->
cbData
;
if
(
pValue
->
cbData
&&
isspace
(
pValue
->
pbData
[
0
]))
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
]))
needsQuotes
=
TRUE
;
if
(
pValue
->
pbData
[
i
]
==
'"'
)
len
+=
1
;
}
if
(
needsQuotes
)
len
+=
2
;
if
(
!
psz
||
!
csz
)
ret
=
pValue
->
cbData
;
ret
=
len
;
else
{
DWORD
chars
=
min
(
pValue
->
cbData
,
csz
-
1
)
;
WCHAR
*
ptr
=
psz
;
if
(
chars
)
if
(
needsQuotes
)
*
ptr
++
=
'"'
;
for
(
i
=
0
;
i
<
pValue
->
cbData
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
{
DWORD
i
;
for
(
i
=
0
;
i
<
chars
;
i
++
)
psz
[
i
]
=
pValue
->
pbData
[
i
];
ret
+=
chars
;
csz
-=
chars
;
*
ptr
=
pValue
->
pbData
[
i
];
if
(
pValue
->
pbData
[
i
]
==
'"'
&&
ptr
-
psz
<
csz
-
1
)
*
(
++
ptr
)
=
'"'
;
}
if
(
needsQuotes
&&
ptr
-
psz
<
csz
)
*
ptr
++
=
'"'
;
ret
=
ptr
-
psz
;
}
break
;
case
CERT_RDN_UTF8_STRING
:
...
...
dlls/crypt32/tests/str.c
View file @
99306803
...
...
@@ -439,20 +439,20 @@ static void test_CertNameToStrA(void)
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN='1'"
,
FALSE
);
blob
.
pbData
=
encodedSpacedCN
;
blob
.
cbData
=
sizeof
(
encodedSpacedCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
1
\"
"
,
TRU
E
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
1
\"
"
,
FALS
E
);
blob
.
pbData
=
encodedQuotedCN
;
blob
.
cbData
=
sizeof
(
encodedQuotedCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"\"\"
1
\"\"\"
"
,
TRUE
);
blob
.
pbData
=
encodedMultipleAttrCN
;
blob
.
cbData
=
sizeof
(
encodedMultipleAttrCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
1+2
\"
"
,
TRU
E
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
1+2
\"
"
,
FALS
E
);
blob
.
pbData
=
encodedCommaCN
;
blob
.
cbData
=
sizeof
(
encodedCommaCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
a,b
\"
"
,
TRU
E
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
a,b
\"
"
,
FALS
E
);
blob
.
pbData
=
encodedEqualCN
;
blob
.
cbData
=
sizeof
(
encodedEqualCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
a=b
\"
"
,
TRU
E
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
a=b
\"
"
,
FALS
E
);
blob
.
pbData
=
encodedLessThanCN
;
blob
.
cbData
=
sizeof
(
encodedLessThanCN
);
test_NameToStrConversionA
(
&
blob
,
CERT_X500_NAME_STR
,
"CN=
\"
<
\"
"
,
TRUE
);
...
...
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