]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix OOB read in TS_OBJ_print_bio().
authorDr. Stephen Henson <steve@openssl.org>
Thu, 21 Jul 2016 14:24:16 +0000 (15:24 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 22 Jul 2016 14:17:38 +0000 (15:17 +0100)
TS_OBJ_print_bio() misuses OBJ_txt2obj: it should print the result
as a null terminated buffer. The length value returned is the total
length the complete text reprsentation would need not the amount of
data written.

CVE-2016-2180

Thanks to Shi Lei for reporting this bug.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 0ed26acce328ec16a3aa635f1ca37365e8c7403a)

crypto/ts/ts_lib.c

index c51538a17f4216f50fd52d3cabc1aa1ad05f67a5..e0f106353723434d62c9b292ac2af2f77fb300da 100644 (file)
@@ -90,9 +90,8 @@ int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj)
 {
     char obj_txt[128];
 
-    int len = OBJ_obj2txt(obj_txt, sizeof(obj_txt), obj, 0);
-    BIO_write(bio, obj_txt, len);
-    BIO_write(bio, "\n", 1);
+    OBJ_obj2txt(obj_txt, sizeof(obj_txt), obj, 0);
+    BIO_printf(bio, "%s\n", obj_txt);
 
     return 1;
 }