summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2024-07-12 08:39:55 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2024-07-12 08:39:55 +0000
commit86d640a6f819dcfdd8f3adba271adf3a47fe42bc (patch)
tree81eb9adb3996efbd895f6ea16ed076ba63f0fbc5 /lib
parentbdfd5002d00a56a8d7fc49ad1ba303675a261857 (diff)
Clean up X509v3_get_ext_by_OBJ()
Like most of its siblings, this function can be simplified significantly by making proper use of the API that is being built. Drop unnecessary NULL checks and other weirdness and add some const correctness. ok jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/x509/x509_v3.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/libcrypto/x509/x509_v3.c b/lib/libcrypto/x509/x509_v3.c
index fcc68973785..22fa7e1162e 100644
--- a/lib/libcrypto/x509/x509_v3.c
+++ b/lib/libcrypto/x509/x509_v3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_v3.c,v 1.30 2024/05/23 02:00:38 tb Exp $ */
+/* $OpenBSD: x509_v3.c,v 1.31 2024/07/12 08:39:54 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -94,20 +94,16 @@ int
X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk,
const ASN1_OBJECT *obj, int lastpos)
{
- int n;
- X509_EXTENSION *ext;
-
- if (sk == NULL)
- return -1;
- lastpos++;
- if (lastpos < 0)
+ if (++lastpos < 0)
lastpos = 0;
- n = sk_X509_EXTENSION_num(sk);
- for (; lastpos < n; lastpos++) {
- ext = sk_X509_EXTENSION_value(sk, lastpos);
+
+ for (; lastpos < X509v3_get_ext_count(sk); lastpos++) {
+ const X509_EXTENSION *ext = X509v3_get_ext(sk, lastpos);
+
if (OBJ_cmp(ext->object, obj) == 0)
return lastpos;
}
+
return -1;
}
LCRYPTO_ALIAS(X509v3_get_ext_by_OBJ);