summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2024-12-28 19:07:24 +0000
committertb <>2024-12-28 19:07:24 +0000
commit2a801fad92517eff7ef232be41af1b086dbb5a50 (patch)
tree2811b55be563695dc99b1e14ae8a70efa30abf28
parent1dcfd9f7169326293f4eea2ac4d8937b6203f987 (diff)
downloadopenbsd-2a801fad92517eff7ef232be41af1b086dbb5a50.tar.gz
openbsd-2a801fad92517eff7ef232be41af1b086dbb5a50.tar.bz2
openbsd-2a801fad92517eff7ef232be41af1b086dbb5a50.zip
Remove flags argument from obj_bsearch_ex()
The only caller passes in OBJ_BSEARCH_FIRST_VALUE_ON_MATCH, so the condition involving this flag is always true. On the other hand, while OBJ_BSEARCh_VALUE_ON_NOMATCH is left unset hence the condition involving this flag is also true (since negated). ok jsing
-rw-r--r--src/lib/libcrypto/stack/stack.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/lib/libcrypto/stack/stack.c b/src/lib/libcrypto/stack/stack.c
index 3967bedfe4..e50c1bcac0 100644
--- a/src/lib/libcrypto/stack/stack.c
+++ b/src/lib/libcrypto/stack/stack.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: stack.c,v 1.29 2024/12/28 16:10:39 tb Exp $ */ 1/* $OpenBSD: stack.c,v 1.30 2024/12/28 19:07:24 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 *
@@ -68,9 +68,6 @@
68#undef MIN_NODES 68#undef MIN_NODES
69#define MIN_NODES 4 69#define MIN_NODES 4
70 70
71#define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01
72#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02
73
74int 71int
75(*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))( 72(*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))(
76 const void *, const void *) 73 const void *, const void *)
@@ -202,7 +199,7 @@ LCRYPTO_ALIAS(sk_delete);
202 199
203static const void * 200static const void *
204obj_bsearch_ex(const void *key, const void *base_, int num, int size, 201obj_bsearch_ex(const void *key, const void *base_, int num, int size,
205 int (*cmp)(const void *, const void *), int flags) 202 int (*cmp)(const void *, const void *))
206{ 203{
207 const char *base = base_; 204 const char *base = base_;
208 int l, h, i = 0, c = 0; 205 int l, h, i = 0, c = 0;
@@ -223,9 +220,9 @@ obj_bsearch_ex(const void *key, const void *base_, int num, int size,
223 else 220 else
224 break; 221 break;
225 } 222 }
226 if (c != 0 && !(flags & OBJ_BSEARCH_VALUE_ON_NOMATCH)) 223 if (c != 0)
227 p = NULL; 224 p = NULL;
228 else if (c == 0 && (flags & OBJ_BSEARCH_FIRST_VALUE_ON_MATCH)) { 225 else if (c == 0) {
229 while (i > 0 && (*cmp)(key, &(base[(i - 1) * size])) == 0) 226 while (i > 0 && (*cmp)(key, &(base[(i - 1) * size])) == 0)
230 i--; 227 i--;
231 p = &(base[i * size]); 228 p = &(base[i * size]);
@@ -251,8 +248,7 @@ sk_find(_STACK *st, void *data)
251 sk_sort(st); 248 sk_sort(st);
252 if (data == NULL) 249 if (data == NULL)
253 return (-1); 250 return (-1);
254 r = obj_bsearch_ex(&data, st->data, st->num, sizeof(void *), st->comp, 251 r = obj_bsearch_ex(&data, st->data, st->num, sizeof(void *), st->comp);
255 OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
256 if (r == NULL) 252 if (r == NULL)
257 return (-1); 253 return (-1);
258 return (int)((char **)r - st->data); 254 return (int)((char **)r - st->data);