summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects/obj_dat.c
diff options
context:
space:
mode:
authortb <>2024-02-26 15:00:30 +0000
committertb <>2024-02-26 15:00:30 +0000
commit11ef2217cacdb92184e7ebd704666c7ad611fceb (patch)
tree2dbd38cc6bf3a73f80f1f2eeb712662582dce17e /src/lib/libcrypto/objects/obj_dat.c
parentcdcdc3f000a66ef2634f3b9ffef752eaab42c119 (diff)
downloadopenbsd-11ef2217cacdb92184e7ebd704666c7ad611fceb.tar.gz
openbsd-11ef2217cacdb92184e7ebd704666c7ad611fceb.tar.bz2
openbsd-11ef2217cacdb92184e7ebd704666c7ad611fceb.zip
Neuter OBJ_bsearch{_,ex_}()
Make these functions always fail. A copy of OBJ_bsearch_ex_() is kept in stack.c, where it is still used by internal_find() for sk_find{,_ex}(). sk_find_ex() will be removed in the upcoming bump, and then we can simplify or rewrite what's still needed. ok jsing
Diffstat (limited to 'src/lib/libcrypto/objects/obj_dat.c')
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c34
1 files changed, 5 insertions, 29 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 170a6d58a3..1719cc73e2 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.85 2024/01/24 14:05:10 jsing Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.86 2024/02/26 15:00:30 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 *
@@ -440,7 +440,8 @@ const void *
440OBJ_bsearch_(const void *key, const void *base, int num, int size, 440OBJ_bsearch_(const void *key, const void *base, int num, int size,
441 int (*cmp)(const void *, const void *)) 441 int (*cmp)(const void *, const void *))
442{ 442{
443 return OBJ_bsearch_ex_(key, base, num, size, cmp, 0); 443 OBJerror(ERR_R_DISABLED);
444 return NULL;
444} 445}
445LCRYPTO_ALIAS(OBJ_bsearch_); 446LCRYPTO_ALIAS(OBJ_bsearch_);
446 447
@@ -448,33 +449,8 @@ const void *
448OBJ_bsearch_ex_(const void *key, const void *base_, int num, int size, 449OBJ_bsearch_ex_(const void *key, const void *base_, int num, int size,
449 int (*cmp)(const void *, const void *), int flags) 450 int (*cmp)(const void *, const void *), int flags)
450{ 451{
451 const char *base = base_; 452 OBJerror(ERR_R_DISABLED);
452 int l, h, i = 0, c = 0; 453 return NULL;
453 const char *p = NULL;
454
455 if (num == 0)
456 return (NULL);
457 l = 0;
458 h = num;
459 while (l < h) {
460 i = (l + h) / 2;
461 p = &(base[i * size]);
462 c = (*cmp)(key, p);
463 if (c < 0)
464 h = i;
465 else if (c > 0)
466 l = i + 1;
467 else
468 break;
469 }
470 if (c != 0 && !(flags & OBJ_BSEARCH_VALUE_ON_NOMATCH))
471 p = NULL;
472 else if (c == 0 && (flags & OBJ_BSEARCH_FIRST_VALUE_ON_MATCH)) {
473 while (i > 0 && (*cmp)(key, &(base[(i - 1) * size])) == 0)
474 i--;
475 p = &(base[i * size]);
476 }
477 return (p);
478} 454}
479 455
480/* Convert an object name into an ASN1_OBJECT 456/* Convert an object name into an ASN1_OBJECT