Skip to content

Commit e10d559

Browse files
committed
Fix DER decoding of UTF-8 Strings
Don't read more than the length indicated by the length field. Signed-off-by: Steffen Jaeckel <[email protected]>
1 parent 0173cac commit e10d559

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/pk/asn1/der/utf8/der_decode_utf8_string.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ int der_decode_utf8_string(const unsigned char *in, unsigned long inlen,
5656
5757
https://tools.ietf.org/html/rfc3629#section-3
5858
*/
59-
for (y = 0; x < inlen; ) {
59+
len += x;
60+
for (y = 0; x < len; ) {
6061
/* read first byte */
6162
tmp = in[x++];
6263

@@ -87,7 +88,7 @@ int der_decode_utf8_string(const unsigned char *in, unsigned long inlen,
8788
/* now update z so it equals the number of additional bytes to read */
8889
if (z > 0) { --z; }
8990

90-
if (x + z > inlen) {
91+
if (x + z > len) {
9192
return CRYPT_INVALID_PACKET;
9293
}
9394

0 commit comments

Comments
 (0)