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
5d168bd4
Commit
5d168bd4
authored
Sep 17, 2007
by
Juan Lang
Committed by
Alexandre Julliard
Sep 18, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Support indefinite-length encoded arrays.
parent
159a3693
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
40 deletions
+62
-40
decode.c
dlls/crypt32/decode.c
+62
-39
encode.c
dlls/crypt32/tests/encode.c
+0
-1
No files found.
dlls/crypt32/decode.c
View file @
5d168bd4
...
...
@@ -536,7 +536,7 @@ static BOOL CRYPT_AsnDecodeArray(const struct AsnArrayDescriptor *arrayDesc,
{
DWORD
dataLen
;
if
((
ret
=
CRYPT_GetLen
(
pbEncoded
,
cbEncoded
,
&
dataLen
)))
if
((
ret
=
CRYPT_GetLen
gthIndefinite
(
pbEncoded
,
cbEncoded
,
&
dataLen
)))
{
DWORD
bytesNeeded
,
cItems
=
0
,
decoded
;
BYTE
lenBytes
=
GET_LEN_BYTES
(
pbEncoded
[
1
]);
...
...
@@ -549,53 +549,76 @@ static BOOL CRYPT_AsnDecodeArray(const struct AsnArrayDescriptor *arrayDesc,
if
(
dataLen
)
{
const
BYTE
*
ptr
;
BOOL
doneDecoding
=
FALSE
;
for
(
ptr
=
pbEncoded
+
1
+
lenBytes
;
ret
&&
ptr
-
pbEncoded
-
1
-
lenBytes
<
dataLen
;
)
for
(
ptr
=
pbEncoded
+
1
+
lenBytes
;
ret
&&
!
doneDecoding
;
)
{
DWORD
itemLenBytes
,
itemDataLen
,
itemDecoded
,
size
=
0
;
DWORD
itemLenBytes
;
itemLenBytes
=
GET_LEN_BYTES
(
ptr
[
1
]);
/* Each item decoded may not tolerate extraneous bytes, so
* get the length of the next element and pass it directly.
*/
ret
=
CRYPT_GetLen
(
ptr
,
cbEncoded
-
(
ptr
-
pbEncoded
),
&
itemDataLen
);
if
(
ret
)
ret
=
arrayDesc
->
decodeFunc
(
ptr
,
1
+
itemLenBytes
+
itemDataLen
,
dwFlags
&
~
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
&
size
,
&
itemDecoded
);
if
(
ret
)
if
(
dataLen
==
CMSG_INDEFINITE_LENGTH
)
{
DWORD
nextLen
;
cItems
++
;
if
(
itemSizes
!=
&
itemSize
)
itemSizes
=
CryptMemRealloc
(
itemSizes
,
cItems
*
sizeof
(
struct
AsnArrayItemSize
));
else
if
(
cItems
>
1
)
if
(
ptr
[
0
]
==
0
)
{
itemSizes
=
CryptMemAlloc
(
cItems
*
sizeof
(
struct
AsnArrayItemSize
));
if
(
itemSizes
)
memcpy
(
itemSizes
,
&
itemSize
,
sizeof
(
itemSize
));
doneDecoding
=
TRUE
;
if
(
itemLenBytes
!=
1
||
ptr
[
1
]
!=
0
)
{
SetLastError
(
CRYPT_E_ASN1_CORRUPT
);
ret
=
FALSE
;
}
else
decoded
+=
2
;
}
if
(
itemSizes
)
}
else
if
(
ptr
-
pbEncoded
-
1
-
lenBytes
>=
dataLen
)
doneDecoding
=
TRUE
;
if
(
!
doneDecoding
)
{
DWORD
itemDataLen
,
itemDecoded
,
size
=
0
;
/* Each item decoded may not tolerate extraneous bytes,
* so get the length of the next element and pass it
* directly.
*/
ret
=
CRYPT_GetLen
(
ptr
,
cbEncoded
-
(
ptr
-
pbEncoded
),
&
itemDataLen
);
if
(
ret
)
ret
=
arrayDesc
->
decodeFunc
(
ptr
,
1
+
itemLenBytes
+
itemDataLen
,
dwFlags
&
~
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
&
size
,
&
itemDecoded
);
if
(
ret
)
{
decoded
+=
itemDecoded
;
itemSizes
[
cItems
-
1
].
encodedLen
=
1
+
itemLenBytes
+
itemDataLen
;
itemSizes
[
cItems
-
1
].
size
=
size
;
bytesNeeded
+=
size
;
ret
=
CRYPT_GetLen
(
ptr
,
cbEncoded
-
(
ptr
-
pbEncoded
),
&
nextLen
);
if
(
ret
)
ptr
+=
nextLen
+
1
+
GET_LEN_BYTES
(
ptr
[
1
]);
DWORD
nextLen
;
cItems
++
;
if
(
itemSizes
!=
&
itemSize
)
itemSizes
=
CryptMemRealloc
(
itemSizes
,
cItems
*
sizeof
(
struct
AsnArrayItemSize
));
else
if
(
cItems
>
1
)
{
itemSizes
=
CryptMemAlloc
(
cItems
*
sizeof
(
struct
AsnArrayItemSize
));
if
(
itemSizes
)
memcpy
(
itemSizes
,
&
itemSize
,
sizeof
(
itemSize
));
}
if
(
itemSizes
)
{
decoded
+=
itemDecoded
;
itemSizes
[
cItems
-
1
].
encodedLen
=
1
+
itemLenBytes
+
itemDataLen
;
itemSizes
[
cItems
-
1
].
size
=
size
;
bytesNeeded
+=
size
;
ret
=
CRYPT_GetLen
(
ptr
,
cbEncoded
-
(
ptr
-
pbEncoded
),
&
nextLen
);
if
(
ret
)
ptr
+=
nextLen
+
1
+
GET_LEN_BYTES
(
ptr
[
1
]);
}
else
ret
=
FALSE
;
}
else
ret
=
FALSE
;
}
}
}
...
...
dlls/crypt32/tests/encode.c
View file @
5d168bd4
...
...
@@ -1015,7 +1015,6 @@ static void test_decodeName(DWORD dwEncoding)
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
X509_NAME
,
emptyIndefiniteSequence
,
sizeof
(
emptyIndefiniteSequence
),
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
bufSize
);
todo_wine
ok
(
ret
,
"CryptDecodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
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