Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
external
mbedtls
Commits
5d861853
Commit
5d861853
authored
Oct 17, 2014
by
Manuel Pégourié-Gonnard
Browse files
Fix memory leak while parsing some X.509 certs
parent
64938c63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
30 deletions
+24
-30
ChangeLog
ChangeLog
+5
-0
library/x509.c
library/x509.c
+18
-29
tests/suites/test_suite_x509parse.data
tests/suites/test_suite_x509parse.data
+1
-1
No files found.
ChangeLog
View file @
5d861853
...
...
@@ -4,6 +4,9 @@ PolarSSL ChangeLog (Sorted per branch, date)
Security
* Lowest common hash was selected from signature_algorithms extension in
TLS 1.2 (found by Darren Bane) (introduced in 1.3.8).
* Remotely-triggerable memory leak when parsing some X.509 certificates
(server is not affected if it doesn't ask for a client certificate).
(Found using Codenomicon Defensics.)
Bugfix
* Support escaping of commas in x509_string_to_names()
...
...
@@ -36,6 +39,8 @@ Changes
* POLARSSL_MPI_MAX_SIZE now defaults to 1024 in order to allow 8192 bits
RSA keys.
* Accept spaces at end of line or end of buffer in base64_decode().
* X.509 certificates with more than one AttributeTypeAndValue per
RelativeDistinguishedName are not accepted any more.
= PolarSSL 1.3.8 released 2014-07-11
Security
...
...
library/x509.c
View file @
5d861853
...
...
@@ -409,58 +409,47 @@ static int x509_get_attr_type_value( unsigned char **p,
* AttributeType ::= OBJECT IDENTIFIER
*
* AttributeValue ::= ANY DEFINED BY AttributeType
*
* We restrict RelativeDistinguishedName to be a set of 1 element. This is
* the most common case, and our x509_name structure currently can't handle
* more than that.
*/
int
x509_get_name
(
unsigned
char
**
p
,
const
unsigned
char
*
end
,
x509_name
*
cur
)
{
int
ret
;
size_t
len
;
const
unsigned
char
*
end2
;
x509_name
*
use
;
size_t
set_len
;
const
unsigned
char
*
end_set
;
if
(
(
ret
=
asn1_get_tag
(
p
,
end
,
&
len
,
/*
* parse first SET, restricted to 1 element
*/
if
(
(
ret
=
asn1_get_tag
(
p
,
end
,
&
set_len
,
ASN1_CONSTRUCTED
|
ASN1_SET
)
)
!=
0
)
return
(
POLARSSL_ERR_X509_INVALID_NAME
+
ret
);
end2
=
end
;
end
=
*
p
+
len
;
use
=
cur
;
do
{
if
(
(
ret
=
x509_get_attr_type_value
(
p
,
end
,
use
)
)
!=
0
)
return
(
ret
);
end_set
=
*
p
+
set_len
;
if
(
*
p
!=
end
)
{
use
->
next
=
(
x509_name
*
)
polarssl_malloc
(
sizeof
(
x509_name
)
);
if
(
use
->
next
==
NULL
)
return
(
POLARSSL_ERR_X509_MALLOC_FAILED
);
if
(
(
ret
=
x509_get_attr_type_value
(
p
,
end_set
,
cur
)
)
!=
0
)
return
(
ret
);
memset
(
use
->
next
,
0
,
sizeof
(
x509_name
)
);
use
=
use
->
next
;
}
}
while
(
*
p
!=
end
);
if
(
*
p
!=
end_set
)
return
(
POLARSSL_ERR_X509_FEATURE_UNAVAILABLE
);
/*
* recurse until end of SEQUENCE is reached
*/
if
(
*
p
==
end
2
)
if
(
*
p
==
end
)
return
(
0
);
cur
->
next
=
(
x509_name
*
)
polarssl_malloc
(
sizeof
(
x509_name
)
);
cur
->
next
=
(
x509_name
*
)
polarssl_malloc
(
sizeof
(
x509_name
)
);
if
(
cur
->
next
==
NULL
)
return
(
POLARSSL_ERR_X509_MALLOC_FAILED
);
memset
(
cur
->
next
,
0
,
sizeof
(
x509_name
)
);
return
(
x509_get_name
(
p
,
end
2
,
cur
->
next
)
);
return
(
x509_get_name
(
p
,
end
,
cur
->
next
)
);
}
/*
...
...
tests/suites/test_suite_x509parse.data
View file @
5d861853
...
...
@@ -750,7 +750,7 @@ X509 Certificate ASN1 (TBSCertificate, issuer, no string data)
x509parse_crt:"30253023a0030201028204deadbeef300d06092a864886f70d0101020500300731053003060013":"":POLARSSL_ERR_X509_INVALID_NAME + POLARSSL_ERR_ASN1_OUT_OF_DATA
X509 Certificate ASN1 (TBSCertificate, issuer, no full following string)
x509parse_crt:"302b3029a0030201028204deadbeef300d06092a864886f70d0101020500300d310b3009060013045465737400":"":POLARSSL_ERR_X509_
INVALID_NAME + POLARSSL_ERR_ASN1_UNEXPECTED_TAG
x509parse_crt:"302b3029a0030201028204deadbeef300d06092a864886f70d0101020500300d310b3009060013045465737400":"":POLARSSL_ERR_X509_
FEATURE_UNAVAILABLE
X509 Certificate ASN1 (TBSCertificate, valid issuer, no validity)
x509parse_crt:"302a3028a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374":"":POLARSSL_ERR_X509_INVALID_DATE + POLARSSL_ERR_ASN1_OUT_OF_DATA
...
...
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