summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-07-12 09:25:43 +0000
committertb <>2024-07-12 09:25:43 +0000
commit03810391db960c63a86f264abe0c6eda1ac49eea (patch)
treec51bf65bf3ecc8ad54c281a60eb4fdb556bd707b /src
parent169d571ee404430f51bf229b3f90aed37a7e8289 (diff)
downloadopenbsd-03810391db960c63a86f264abe0c6eda1ac49eea.tar.gz
openbsd-03810391db960c63a86f264abe0c6eda1ac49eea.tar.bz2
openbsd-03810391db960c63a86f264abe0c6eda1ac49eea.zip
Clean up X509_EXTENSION_create_by_NID()
Remove unnecessary ret parameter and freeing of obj (which looks like a double free or freeing of unallocated memory but actually isn't due to various magic flags). Also make this const correct. ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/x509/x509_v3.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c
index b0a30db2e8..76e9777c25 100644
--- a/src/lib/libcrypto/x509/x509_v3.c
+++ b/src/lib/libcrypto/x509/x509_v3.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_v3.c,v 1.34 2024/07/12 08:58:59 tb Exp $ */ 1/* $OpenBSD: x509_v3.c,v 1.35 2024/07/12 09:25:43 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 *
@@ -188,18 +188,14 @@ X509_EXTENSION *
188X509_EXTENSION_create_by_NID(X509_EXTENSION **ext, int nid, int crit, 188X509_EXTENSION_create_by_NID(X509_EXTENSION **ext, int nid, int crit,
189 ASN1_OCTET_STRING *data) 189 ASN1_OCTET_STRING *data)
190{ 190{
191 ASN1_OBJECT *obj; 191 const ASN1_OBJECT *obj;
192 X509_EXTENSION *ret;
193 192
194 obj = OBJ_nid2obj(nid); 193 if ((obj = OBJ_nid2obj(nid)) == NULL) {
195 if (obj == NULL) {
196 X509error(X509_R_UNKNOWN_NID); 194 X509error(X509_R_UNKNOWN_NID);
197 return NULL; 195 return NULL;
198 } 196 }
199 ret = X509_EXTENSION_create_by_OBJ(ext, obj, crit, data); 197
200 if (ret == NULL) 198 return X509_EXTENSION_create_by_OBJ(ext, obj, crit, data);
201 ASN1_OBJECT_free(obj);
202 return ret;
203} 199}
204LCRYPTO_ALIAS(X509_EXTENSION_create_by_NID); 200LCRYPTO_ALIAS(X509_EXTENSION_create_by_NID);
205 201