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
74cf35d2
Commit
74cf35d2
authored
Feb 01, 2011
by
Juan Lang
Committed by
Alexandre Julliard
Feb 02, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Fix string quoting in CertRDNValueToStrA/W and CertNameToStrA/W.
Based on an idea of Christian Inci's.
parent
307e247f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
16 deletions
+143
-16
str.c
dlls/crypt32/str.c
+133
-6
str.c
dlls/crypt32/tests/str.c
+10
-10
No files found.
dlls/crypt32/str.c
View file @
74cf35d2
...
...
@@ -29,6 +29,133 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
crypt
);
DWORD
WINAPI
CertRDNValueToStrA
(
DWORD
dwValueType
,
PCERT_RDN_VALUE_BLOB
pValue
,
LPSTR
psz
,
DWORD
csz
)
{
DWORD
ret
=
0
,
len
;
TRACE
(
"(%d, %p, %p, %d)
\n
"
,
dwValueType
,
pValue
,
psz
,
csz
);
switch
(
dwValueType
)
{
case
CERT_RDN_ANY_TYPE
:
break
;
case
CERT_RDN_NUMERIC_STRING
:
case
CERT_RDN_PRINTABLE_STRING
:
case
CERT_RDN_TELETEX_STRING
:
case
CERT_RDN_VIDEOTEX_STRING
:
case
CERT_RDN_IA5_STRING
:
case
CERT_RDN_GRAPHIC_STRING
:
case
CERT_RDN_VISIBLE_STRING
:
case
CERT_RDN_GENERAL_STRING
:
len
=
pValue
->
cbData
;
if
(
!
psz
||
!
csz
)
ret
=
len
;
else
{
DWORD
chars
=
min
(
len
,
csz
-
1
);
if
(
chars
)
{
memcpy
(
psz
,
pValue
->
pbData
,
chars
);
ret
+=
chars
;
csz
-=
chars
;
}
}
break
;
case
CERT_RDN_BMP_STRING
:
case
CERT_RDN_UTF8_STRING
:
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
LPCWSTR
)
pValue
->
pbData
,
pValue
->
cbData
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
if
(
!
psz
||
!
csz
)
ret
=
len
;
else
{
DWORD
chars
=
min
(
pValue
->
cbData
/
sizeof
(
WCHAR
),
csz
-
1
);
if
(
chars
)
{
ret
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
LPCWSTR
)
pValue
->
pbData
,
chars
,
psz
,
csz
-
1
,
NULL
,
NULL
);
csz
-=
ret
;
}
}
break
;
default:
FIXME
(
"string type %d unimplemented
\n
"
,
dwValueType
);
}
if
(
psz
&&
csz
)
{
*
(
psz
+
ret
)
=
'\0'
;
csz
--
;
ret
++
;
}
else
ret
++
;
TRACE
(
"returning %d (%s)
\n
"
,
ret
,
debugstr_a
(
psz
));
return
ret
;
}
DWORD
WINAPI
CertRDNValueToStrW
(
DWORD
dwValueType
,
PCERT_RDN_VALUE_BLOB
pValue
,
LPWSTR
psz
,
DWORD
csz
)
{
DWORD
ret
=
0
,
len
,
i
,
strLen
;
TRACE
(
"(%d, %p, %p, %d)
\n
"
,
dwValueType
,
pValue
,
psz
,
csz
);
switch
(
dwValueType
)
{
case
CERT_RDN_ANY_TYPE
:
break
;
case
CERT_RDN_NUMERIC_STRING
:
case
CERT_RDN_PRINTABLE_STRING
:
case
CERT_RDN_TELETEX_STRING
:
case
CERT_RDN_VIDEOTEX_STRING
:
case
CERT_RDN_IA5_STRING
:
case
CERT_RDN_GRAPHIC_STRING
:
case
CERT_RDN_VISIBLE_STRING
:
case
CERT_RDN_GENERAL_STRING
:
len
=
pValue
->
cbData
;
if
(
!
psz
||
!
csz
)
ret
=
len
;
else
{
WCHAR
*
ptr
=
psz
;
for
(
i
=
0
;
i
<
pValue
->
cbData
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
*
ptr
=
pValue
->
pbData
[
i
];
ret
=
ptr
-
psz
;
}
break
;
case
CERT_RDN_BMP_STRING
:
case
CERT_RDN_UTF8_STRING
:
strLen
=
len
=
pValue
->
cbData
/
sizeof
(
WCHAR
);
if
(
!
psz
||
!
csz
)
ret
=
len
;
else
{
WCHAR
*
ptr
=
psz
;
for
(
i
=
0
;
i
<
strLen
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
*
ptr
=
((
LPCWSTR
)
pValue
->
pbData
)[
i
];
ret
=
ptr
-
psz
;
}
break
;
default:
FIXME
(
"string type %d unimplemented
\n
"
,
dwValueType
);
}
if
(
psz
&&
csz
)
{
*
(
psz
+
ret
)
=
'\0'
;
csz
--
;
ret
++
;
}
else
ret
++
;
TRACE
(
"returning %d (%s)
\n
"
,
ret
,
debugstr_w
(
psz
));
return
ret
;
}
static
inline
BOOL
is_quotable_char
(
char
c
)
{
switch
(
c
)
...
...
@@ -48,8 +175,8 @@ static inline BOOL is_quotable_char(char c)
}
}
DWORD
WINAPI
CertRDNValueToStrA
(
DWORD
dwValueType
,
PCERT_RDN_VALUE_BLOB
pValu
e
,
LPSTR
psz
,
DWORD
csz
)
static
DWORD
quote_rdn_value_to_str_a
(
DWORD
dwValueTyp
e
,
PCERT_RDN_VALUE_BLOB
pValue
,
LPSTR
psz
,
DWORD
csz
)
{
DWORD
ret
=
0
,
len
,
i
;
BOOL
needsQuotes
=
FALSE
;
...
...
@@ -157,8 +284,8 @@ DWORD WINAPI CertRDNValueToStrA(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
return
ret
;
}
DWORD
WINAPI
CertRDNValueToStrW
(
DWORD
dwValueType
,
PCERT_RDN_VALUE_BLOB
pValu
e
,
LPWSTR
psz
,
DWORD
csz
)
static
DWORD
quote_rdn_value_to_str_w
(
DWORD
dwValueTyp
e
,
PCERT_RDN_VALUE_BLOB
pValue
,
LPWSTR
psz
,
DWORD
csz
)
{
DWORD
ret
=
0
,
len
,
i
,
strLen
;
BOOL
needsQuotes
=
FALSE
;
...
...
@@ -358,7 +485,7 @@ DWORD WINAPI CertNameToStrA(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
psz
?
psz
+
ret
:
NULL
,
psz
?
csz
-
ret
-
1
:
0
);
ret
+=
chars
;
}
chars
=
CertRDNValueToStrA
(
chars
=
quote_rdn_value_to_str_a
(
rdn
->
rgRDNAttr
[
j
].
dwValueType
,
&
rdn
->
rgRDNAttr
[
j
].
Value
,
psz
?
psz
+
ret
:
NULL
,
psz
?
csz
-
ret
:
0
);
...
...
@@ -537,7 +664,7 @@ DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indentLevel,
psz
?
psz
+
ret
:
NULL
,
psz
?
csz
-
ret
-
1
:
0
);
ret
+=
chars
;
}
chars
=
CertRDNValueToStrW
(
chars
=
quote_rdn_value_to_str_w
(
rdn
->
rgRDNAttr
[
j
].
dwValueType
,
&
rdn
->
rgRDNAttr
[
j
].
Value
,
psz
?
psz
+
ret
:
NULL
,
psz
?
csz
-
ret
:
0
);
...
...
dlls/crypt32/tests/str.c
View file @
74cf35d2
...
...
@@ -227,17 +227,17 @@ static void test_CertRDNValueToStrA(void)
{
"1.2.840.113549.1.9.1"
,
CERT_RDN_IA5_STRING
,
{
sizeof
(
bin7
),
bin7
},
"aric@codeweavers.com"
,
FALSE
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin9
),
bin9
},
"abc
\"
def"
,
TRU
E
},
{
sizeof
(
bin9
),
bin9
},
"abc
\"
def"
,
FALS
E
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin10
),
bin10
},
"abc'def"
,
FALSE
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin11
),
bin11
},
"abc, def"
,
TRU
E
},
{
sizeof
(
bin11
),
bin11
},
"abc, def"
,
FALS
E
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin12
),
bin12
},
" abc "
,
TRU
E
},
{
sizeof
(
bin12
),
bin12
},
" abc "
,
FALS
E
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin13
),
bin13
},
"
\"
def
\"
"
,
TRU
E
},
{
sizeof
(
bin13
),
bin13
},
"
\"
def
\"
"
,
FALS
E
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin14
),
bin14
},
"1;3"
,
TRU
E
},
{
sizeof
(
bin14
),
bin14
},
"1;3"
,
FALS
E
},
};
DWORD
i
,
ret
;
char
buffer
[
2000
];
...
...
@@ -328,17 +328,17 @@ static void test_CertRDNValueToStrW(void)
{
"1.2.840.113549.1.9.1"
,
CERT_RDN_IA5_STRING
,
{
sizeof
(
bin7
),
bin7
},
aricW
,
FALSE
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin9
),
bin9
},
embeddedDoubleQuoteW
,
TRU
E
},
{
sizeof
(
bin9
),
bin9
},
embeddedDoubleQuoteW
,
FALS
E
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin10
),
bin10
},
embeddedSingleQuoteW
,
FALSE
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin11
),
bin11
},
embeddedCommaW
,
TRU
E
},
{
sizeof
(
bin11
),
bin11
},
embeddedCommaW
,
FALS
E
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin12
),
bin12
},
trailingAndEndingSpaceW
,
TRU
E
},
{
sizeof
(
bin12
),
bin12
},
trailingAndEndingSpaceW
,
FALS
E
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin13
),
bin13
},
enclosingQuotesW
,
TRU
E
},
{
sizeof
(
bin13
),
bin13
},
enclosingQuotesW
,
FALS
E
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin14
),
bin14
},
embeddedSemiW
,
TRU
E
},
{
sizeof
(
bin14
),
bin14
},
embeddedSemiW
,
FALS
E
},
};
DWORD
i
,
ret
;
WCHAR
buffer
[
2000
];
...
...
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