summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects
diff options
context:
space:
mode:
authorguenther <>2014-08-08 04:53:43 +0000
committerguenther <>2014-08-08 04:53:43 +0000
commitc6985e683db078656f9f4ec499be1ef35bdce285 (patch)
tree3d49e2ab368dd2c4623345f392a9a87627e2d9ff /src/lib/libcrypto/objects
parent32554492a8d665d7c0517b374f2ea31089caa176 (diff)
downloadopenbsd-c6985e683db078656f9f4ec499be1ef35bdce285.tar.gz
openbsd-c6985e683db078656f9f4ec499be1ef35bdce285.tar.bz2
openbsd-c6985e683db078656f9f4ec499be1ef35bdce285.zip
Fix CVE-2014-3508, pretty printing and OID validation:
- make sure the output buffer is always NUL terminated if buf_len was initially greater than zero. - reject OIDs that are too long, too short, or not in proper base-127 Based on https://git.openssl.org/gitweb/?p=openssl.git;a=commit;h=0042fb5fd1c9d257d713b15a1f45da05cf5c1c87 ok bcook@
Diffstat (limited to 'src/lib/libcrypto/objects')
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 071febba52..15c298e333 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: obj_dat.c,v 1.30 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.31 2014/08/08 04:53:43 guenther Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -495,6 +495,10 @@ OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
495 unsigned long l; 495 unsigned long l;
496 const unsigned char *p; 496 const unsigned char *p;
497 497
498 /* Ensure that, at every state, |buf| is NUL-terminated. */
499 if (buf_len > 0)
500 buf[0] = '\0';
501
498 if ((a == NULL) || (a->data == NULL)) 502 if ((a == NULL) || (a->data == NULL))
499 goto err; 503 goto err;
500 504
@@ -554,8 +558,9 @@ OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
554 i = (int)(l / 40); 558 i = (int)(l / 40);
555 l -= (long)(i * 40); 559 l -= (long)(i * 40);
556 } 560 }
557 if (buf_len > 0) { 561 if (buf_len > 1) {
558 *buf++ = i + '0'; 562 *buf++ = i + '0';
563 *buf = '\0';
559 buf_len--; 564 buf_len--;
560 } 565 }
561 ret++; 566 ret++;