diff options
| author | tb <> | 2024-07-12 08:44:16 +0000 |
|---|---|---|
| committer | tb <> | 2024-07-12 08:44:16 +0000 |
| commit | 917a1e7030406b9350a24748b055d9f6f373dc56 (patch) | |
| tree | ce296ec59c6b01556ac7c022cc2177ed8d830d37 | |
| parent | 20bb4336e5059954a5b909543bcf1225f083e31a (diff) | |
| download | openbsd-917a1e7030406b9350a24748b055d9f6f373dc56.tar.gz openbsd-917a1e7030406b9350a24748b055d9f6f373dc56.tar.bz2 openbsd-917a1e7030406b9350a24748b055d9f6f373dc56.zip | |
Align X509v3_get_ext_by_critical() with X509v3_get_ext_by_OBJ()
Plus, replace a manual check with a call to X509_EXTENSION_get_critical().
ok jsing
| -rw-r--r-- | src/lib/libcrypto/x509/x509_v3.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c index 22fa7e1162..5e8257ff83 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.31 2024/07/12 08:39:54 tb Exp $ */ | 1 | /* $OpenBSD: x509_v3.c,v 1.32 2024/07/12 08:44:16 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 | * |
| @@ -112,21 +112,18 @@ int | |||
| 112 | X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit, | 112 | X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit, |
| 113 | int lastpos) | 113 | int lastpos) |
| 114 | { | 114 | { |
| 115 | int n; | 115 | crit = (crit != 0); |
| 116 | X509_EXTENSION *ext; | ||
| 117 | 116 | ||
| 118 | if (sk == NULL) | 117 | if (++lastpos < 0) |
| 119 | return -1; | ||
| 120 | lastpos++; | ||
| 121 | if (lastpos < 0) | ||
| 122 | lastpos = 0; | 118 | lastpos = 0; |
| 123 | n = sk_X509_EXTENSION_num(sk); | 119 | |
| 124 | for (; lastpos < n; lastpos++) { | 120 | for (; lastpos < X509v3_get_ext_count(sk); lastpos++) { |
| 125 | ext = sk_X509_EXTENSION_value(sk, lastpos); | 121 | const X509_EXTENSION *ext = X509v3_get_ext(sk, lastpos); |
| 126 | if ((ext->critical > 0 && crit) || | 122 | |
| 127 | (ext->critical <= 0 && !crit)) | 123 | if (X509_EXTENSION_get_critical(ext) == crit) |
| 128 | return lastpos; | 124 | return lastpos; |
| 129 | } | 125 | } |
| 126 | |||
| 130 | return -1; | 127 | return -1; |
| 131 | } | 128 | } |
| 132 | LCRYPTO_ALIAS(X509v3_get_ext_by_critical); | 129 | LCRYPTO_ALIAS(X509v3_get_ext_by_critical); |
