Fix OOB read in TS_OBJ_print_bio() 54/133354/1
authormin7.choi <min7.choi@samsung.com>
Mon, 12 Jun 2017 01:57:03 +0000 (10:57 +0900)
committermin7.choi <min7.choi@samsung.com>
Mon, 12 Jun 2017 01:57:07 +0000 (10:57 +0900)
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.

Change-Id: I5346552f8167079c2e1c3c63ea59eae31d7607e8
Signed-off-by: min7.choi <min7.choi@samsung.com>
deps/openssl/openssl/crypto/ts/ts_lib.c

index c51538a..e0f1063 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;
 }