Skip to content

Commit

Permalink
Fix OOB read in TS_OBJ_print_bio().
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
snhenson committed Jul 22, 2016
1 parent d0c4415 commit 0ed26ac
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crypto/ts/ts_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,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;
}
Expand Down

0 comments on commit 0ed26ac

Please sign in to comment.