summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-12-14 18:12:51 +0000
committertb <>2023-12-14 18:12:51 +0000
commit4334947bc18dd3a30c548b4ae0a165409fa58ebb (patch)
tree44049373f1bac6d99f10ec6b7d1fe05b84e456ad
parenteb9b40dedec3bc660a67bc29b191724282e94391 (diff)
downloadopenbsd-4334947bc18dd3a30c548b4ae0a165409fa58ebb.tar.gz
openbsd-4334947bc18dd3a30c548b4ae0a165409fa58ebb.tar.bz2
openbsd-4334947bc18dd3a30c548b4ae0a165409fa58ebb.zip
OBJ_create: initialize buf and turn function into single exit
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index b58e8cfe94..600c3a66a6 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.75 2023/12/14 18:10:32 tb Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.76 2023/12/14 18:12:51 tb 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 *
@@ -590,17 +590,17 @@ int
590OBJ_create(const char *oid, const char *sn, const char *ln) 590OBJ_create(const char *oid, const char *sn, const char *ln)
591{ 591{
592 ASN1_OBJECT *op = NULL; 592 ASN1_OBJECT *op = NULL;
593 unsigned char *buf; 593 unsigned char *buf = NULL;
594 int len; 594 int len;
595 int ret = 0; 595 int ret = 0;
596 596
597 len = a2d_ASN1_OBJECT(NULL, 0, oid, -1); 597 len = a2d_ASN1_OBJECT(NULL, 0, oid, -1);
598 if (len <= 0) 598 if (len <= 0)
599 return 0; 599 goto err;
600 600
601 if ((buf = malloc(len)) == NULL) { 601 if ((buf = malloc(len)) == NULL) {
602 OBJerror(ERR_R_MALLOC_FAILURE); 602 OBJerror(ERR_R_MALLOC_FAILURE);
603 return 0; 603 goto err;
604 } 604 }
605 len = a2d_ASN1_OBJECT(buf, len, oid, -1); 605 len = a2d_ASN1_OBJECT(buf, len, oid, -1);
606 if (len == 0) 606 if (len == 0)
@@ -613,6 +613,7 @@ OBJ_create(const char *oid, const char *sn, const char *ln)
613 err: 613 err:
614 ASN1_OBJECT_free(op); 614 ASN1_OBJECT_free(op);
615 free(buf); 615 free(buf);
616
616 return ret; 617 return ret;
617} 618}
618LCRYPTO_ALIAS(OBJ_create); 619LCRYPTO_ALIAS(OBJ_create);