diff options
author | tb <> | 2021-10-21 16:03:17 +0000 |
---|---|---|
committer | tb <> | 2021-10-21 16:03:17 +0000 |
commit | 4cfbd873a9384e1d78aa5a97546a95524597891e (patch) | |
tree | 0b2cd423347d3395daf536e4b011f0fdbf8a52c3 | |
parent | f4f28ec1b98b4eda170852b2ca8bf94715cc4f7c (diff) | |
download | openbsd-4cfbd873a9384e1d78aa5a97546a95524597891e.tar.gz openbsd-4cfbd873a9384e1d78aa5a97546a95524597891e.tar.bz2 openbsd-4cfbd873a9384e1d78aa5a97546a95524597891e.zip |
Sync parts of X509_STORE_get_by_subject() with OpenSSL
Initialize stmp.type and stmp.data.ptr so that a user-defined lookup
method need not take responsibility of initializing those. Get rid of
current_method, which was never really used. Stop potentially returning
a negative value since most callers assume Boolean return values already.
In addition, garbage collect the pointless j variable.
ok jsing
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/x509/x509_lu.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/lib/libcrypto/x509/x509_lu.c b/src/lib/libcrypto/x509/x509_lu.c index 315eddf612..4336fb90f2 100644 --- a/src/lib/libcrypto/x509/x509_lu.c +++ b/src/lib/libcrypto/x509/x509_lu.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_lu.c,v 1.31 2021/10/06 08:29:41 claudio Exp $ */ | 1 | /* $OpenBSD: x509_lu.c,v 1.32 2021/10/21 16:03:17 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 | * |
@@ -310,36 +310,30 @@ X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name, | |||
310 | X509_STORE *ctx = vs->ctx; | 310 | X509_STORE *ctx = vs->ctx; |
311 | X509_LOOKUP *lu; | 311 | X509_LOOKUP *lu; |
312 | X509_OBJECT stmp, *tmp; | 312 | X509_OBJECT stmp, *tmp; |
313 | int i, j; | 313 | int i; |
314 | 314 | ||
315 | if (ctx == NULL) | 315 | if (ctx == NULL) |
316 | return 0; | 316 | return 0; |
317 | 317 | ||
318 | stmp.type = 0; | ||
319 | stmp.data.ptr = NULL; | ||
320 | |||
318 | CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); | 321 | CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); |
319 | tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name); | 322 | tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name); |
320 | CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); | 323 | CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); |
321 | 324 | ||
322 | if (tmp == NULL || type == X509_LU_CRL) { | 325 | if (tmp == NULL || type == X509_LU_CRL) { |
323 | for (i = vs->current_method; | 326 | for (i = 0; i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) { |
324 | i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) { | ||
325 | lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i); | 327 | lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i); |
326 | j = X509_LOOKUP_by_subject(lu, type, name, &stmp); | 328 | if (X509_LOOKUP_by_subject(lu, type, name, &stmp) != 0) { |
327 | if (j < 0) { | ||
328 | vs->current_method = j; | ||
329 | return j; | ||
330 | } else if (j) { | ||
331 | tmp = &stmp; | 329 | tmp = &stmp; |
332 | break; | 330 | break; |
333 | } | 331 | } |
334 | } | 332 | } |
335 | vs->current_method = 0; | ||
336 | if (tmp == NULL) | 333 | if (tmp == NULL) |
337 | return 0; | 334 | return 0; |
338 | } | 335 | } |
339 | 336 | ||
340 | /* if (ret->data.ptr != NULL) | ||
341 | X509_OBJECT_free_contents(ret); */ | ||
342 | |||
343 | ret->type = tmp->type; | 337 | ret->type = tmp->type; |
344 | ret->data.ptr = tmp->data.ptr; | 338 | ret->data.ptr = tmp->data.ptr; |
345 | 339 | ||