Ensure we don't write a 0 byte past end of the buffer in the error case.
authorbeck <beck@openbsd.org>
Wed, 14 Oct 2015 21:02:08 +0000 (21:02 +0000)
committerbeck <beck@openbsd.org>
Wed, 14 Oct 2015 21:02:08 +0000 (21:02 +0000)
ok bcook@ deraadt@

lib/libcrypto/objects/obj_dat.c
lib/libssl/src/crypto/objects/obj_dat.c

index 15c298e..82ebb9b 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: obj_dat.c,v 1.31 2014/08/08 04:53:43 guenther Exp $ */
+/* $OpenBSD: obj_dat.c,v 1.32 2015/10/14 21:02:08 beck Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -574,7 +574,7 @@ OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
                        if (i == -1)
                                goto err;
                        if (i >= buf_len) {
-                               buf += buf_len;
+                               buf += buf_len - 1;
                                buf_len = 0;
                        } else {
                                buf += i;
@@ -586,7 +586,7 @@ OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
                        if (i == -1)
                                goto err;
                        if (i >= buf_len) {
-                               buf += buf_len;
+                               buf += buf_len - 1;
                                buf_len = 0;
                        } else {
                                buf += i;
index 15c298e..82ebb9b 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: obj_dat.c,v 1.31 2014/08/08 04:53:43 guenther Exp $ */
+/* $OpenBSD: obj_dat.c,v 1.32 2015/10/14 21:02:08 beck Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -574,7 +574,7 @@ OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
                        if (i == -1)
                                goto err;
                        if (i >= buf_len) {
-                               buf += buf_len;
+                               buf += buf_len - 1;
                                buf_len = 0;
                        } else {
                                buf += i;
@@ -586,7 +586,7 @@ OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
                        if (i == -1)
                                goto err;
                        if (i >= buf_len) {
-                               buf += buf_len;
+                               buf += buf_len - 1;
                                buf_len = 0;
                        } else {
                                buf += i;