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
a78f2319
Commit
a78f2319
authored
Apr 14, 2022
by
Paul Gofman
Committed by
Alexandre Julliard
May 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Fix filling short output in CertRDNValueToStrW().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
61957d82
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
47 deletions
+43
-47
str.c
dlls/crypt32/str.c
+14
-24
str.c
dlls/crypt32/tests/str.c
+29
-23
No files found.
dlls/crypt32/str.c
View file @
a78f2319
...
...
@@ -99,7 +99,7 @@ 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
,
len
,
i
,
strLen
;
DWORD
ret
=
0
,
len
,
i
;
TRACE
(
"(%ld, %p, %p, %ld)
\n
"
,
dwValueType
,
pValue
,
psz
,
csz
);
...
...
@@ -116,44 +116,34 @@ DWORD WINAPI CertRDNValueToStrW(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
case
CERT_RDN_VISIBLE_STRING
:
case
CERT_RDN_GENERAL_STRING
:
len
=
pValue
->
cbData
;
if
(
!
psz
||
!
csz
)
ret
=
len
;
else
if
(
!
psz
||
!
csz
)
ret
=
len
;
else
if
(
len
<
csz
)
{
WCHAR
*
ptr
=
psz
;
for
(
i
=
0
;
i
<
pValue
->
cbData
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
*
ptr
=
pValue
->
pbData
[
i
];
ret
=
ptr
-
psz
;
for
(
i
=
0
;
i
<
len
;
++
i
)
psz
[
i
]
=
pValue
->
pbData
[
i
];
ret
=
len
;
}
break
;
case
CERT_RDN_BMP_STRING
:
case
CERT_RDN_UTF8_STRING
:
strLen
=
len
=
pValue
->
cbData
/
sizeof
(
WCHAR
);
len
=
pValue
->
cbData
/
sizeof
(
WCHAR
);
if
(
!
psz
||
!
csz
)
ret
=
len
;
else
else
if
(
len
<
csz
)
{
WCHAR
*
ptr
=
psz
;
for
(
i
=
0
;
i
<
strLen
&&
ptr
-
psz
<
csz
;
ptr
++
,
i
++
)
*
ptr
=
((
LPCWSTR
)
pValue
->
pbData
)[
i
];
ret
=
ptr
-
psz
;
for
(
i
=
0
;
i
<
len
;
++
i
)
ptr
[
i
]
=
((
LPCWSTR
)
pValue
->
pbData
)[
i
];
ret
=
len
;
}
break
;
default:
FIXME
(
"string type %ld unimplemented
\n
"
,
dwValueType
);
}
if
(
psz
&&
csz
)
{
*
(
psz
+
ret
)
=
'\0'
;
csz
--
;
ret
++
;
}
else
ret
++
;
TRACE
(
"returning %ld (%s)
\n
"
,
ret
,
debugstr_w
(
psz
));
return
ret
;
if
(
psz
&&
csz
)
psz
[
ret
]
=
0
;
TRACE
(
"returning %ld (%s)
\n
"
,
ret
+
1
,
debugstr_w
(
psz
));
return
ret
+
1
;
}
static
inline
BOOL
is_quotable_char
(
WCHAR
c
)
...
...
dlls/crypt32/tests/str.c
View file @
a78f2319
...
...
@@ -39,7 +39,6 @@ typedef struct _CertRDNAttrEncodingW {
DWORD
dwValueType
;
CERT_RDN_VALUE_BLOB
Value
;
LPCWSTR
str
;
BOOL
todo
;
}
CertRDNAttrEncodingW
,
*
PCertRDNAttrEncodingW
;
static
BYTE
bin1
[]
=
{
0x55
,
0x53
};
...
...
@@ -202,33 +201,34 @@ static void test_CertRDNValueToStrW(void)
static
const
WCHAR
ePKIW
[]
=
L"ePKI Root Certification Authority"
;
CertRDNAttrEncodingW
attrs
[]
=
{
{
"2.5.4.6"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin1
),
bin1
},
L"US"
,
FALSE
},
{
sizeof
(
bin1
),
bin1
},
L"US"
},
{
"2.5.4.8"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin2
),
bin2
},
L"Minnesota"
,
FALSE
},
{
sizeof
(
bin2
),
bin2
},
L"Minnesota"
},
{
"2.5.4.7"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin3
),
bin3
},
L"Minneapolis"
,
FALSE
},
{
sizeof
(
bin3
),
bin3
},
L"Minneapolis"
},
{
"2.5.4.10"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin4
),
bin4
},
L"CodeWeavers"
,
FALSE
},
{
sizeof
(
bin4
),
bin4
},
L"CodeWeavers"
},
{
"2.5.4.11"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin5
),
bin5
},
L"Wine Development"
,
FALSE
},
{
sizeof
(
bin5
),
bin5
},
L"Wine Development"
},
{
"2.5.4.3"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin6
),
bin6
},
L"localhost"
,
FALSE
},
{
sizeof
(
bin6
),
bin6
},
L"localhost"
},
{
"1.2.840.113549.1.9.1"
,
CERT_RDN_IA5_STRING
,
{
sizeof
(
bin7
),
bin7
},
L"aric@codeweavers.com"
,
FALSE
},
{
sizeof
(
bin7
),
bin7
},
L"aric@codeweavers.com"
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin9
),
bin9
},
L"abc
\"
def"
,
FALSE
},
{
sizeof
(
bin9
),
bin9
},
L"abc
\"
def"
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin10
),
bin10
},
L"abc'def"
,
FALSE
},
{
sizeof
(
bin10
),
bin10
},
L"abc'def"
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin11
),
bin11
},
L"abc, def"
,
FALSE
},
{
sizeof
(
bin11
),
bin11
},
L"abc, def"
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin12
),
bin12
},
L" abc "
,
FALSE
},
{
sizeof
(
bin12
),
bin12
},
L" abc "
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin13
),
bin13
},
L"
\"
def
\"
"
,
FALSE
},
{
sizeof
(
bin13
),
bin13
},
L"
\"
def
\"
"
},
{
"0"
,
CERT_RDN_PRINTABLE_STRING
,
{
sizeof
(
bin14
),
bin14
},
L"1;3"
,
FALSE
},
{
sizeof
(
bin14
),
bin14
},
L"1;3"
},
};
DWORD
i
,
ret
;
unsigned
int
i
;
DWORD
ret
,
len
;
WCHAR
buffer
[
2000
];
CERT_RDN_VALUE_BLOB
blob
=
{
0
,
NULL
};
...
...
@@ -245,14 +245,20 @@ static void test_CertRDNValueToStrW(void)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
attrs
);
i
++
)
{
ret
=
CertRDNValueToStrW
(
attrs
[
i
].
dwValueType
,
&
attrs
[
i
].
Value
,
buffer
,
ARRAY_SIZE
(
buffer
));
todo_wine_if
(
attrs
[
i
].
todo
)
{
ok
(
ret
==
lstrlenW
(
attrs
[
i
].
str
)
+
1
,
"Expected length %d, got %ld
\n
"
,
lstrlenW
(
attrs
[
i
].
str
)
+
1
,
ret
);
ok
(
!
lstrcmpW
(
buffer
,
attrs
[
i
].
str
),
"Expected %s, got %s
\n
"
,
wine_dbgstr_w
(
attrs
[
i
].
str
),
wine_dbgstr_w
(
buffer
));
}
len
=
CertRDNValueToStrW
(
attrs
[
i
].
dwValueType
,
&
attrs
[
i
].
Value
,
buffer
,
ARRAY_SIZE
(
buffer
));
ok
(
len
==
lstrlenW
(
attrs
[
i
].
str
)
+
1
,
"Expected length %d, got %ld
\n
"
,
lstrlenW
(
attrs
[
i
].
str
)
+
1
,
ret
);
ok
(
!
lstrcmpW
(
buffer
,
attrs
[
i
].
str
),
"Expected %s, got %s
\n
"
,
wine_dbgstr_w
(
attrs
[
i
].
str
),
wine_dbgstr_w
(
buffer
));
memset
(
buffer
,
0xcc
,
sizeof
(
buffer
));
ret
=
CertRDNValueToStrW
(
attrs
[
i
].
dwValueType
,
&
attrs
[
i
].
Value
,
buffer
,
len
-
1
);
ok
(
ret
==
1
,
"Unexpected ret %lu, expected 1, test %u.
\n
"
,
ret
,
i
);
ok
(
!
buffer
[
0
],
"Unexpected value %#x, test %u.
\n
"
,
buffer
[
0
],
i
);
ok
(
buffer
[
1
]
==
0xcccc
,
"Unexpected value %#x, test %u.
\n
"
,
buffer
[
1
],
i
);
memset
(
buffer
,
0xcc
,
sizeof
(
buffer
));
ret
=
CertRDNValueToStrW
(
attrs
[
i
].
dwValueType
,
&
attrs
[
i
].
Value
,
buffer
,
0
);
ok
(
ret
==
len
,
"Unexpected ret %lu, expected %lu, test %u.
\n
"
,
ret
,
len
,
i
);
ok
(
buffer
[
0
]
==
0xcccc
,
"Unexpected value %#x, test %u.
\n
"
,
buffer
[
0
],
i
);
}
blob
.
pbData
=
bin8
;
blob
.
cbData
=
sizeof
(
bin8
);
...
...
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