summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2023-08-17 09:18:21 +0000
committertb <>2023-08-17 09:18:21 +0000
commit129c2cdcfb40e6b942b798ab40091669eac48a9f (patch)
tree58a16e410a1db68f127ccfd58ee30c53253a4177 /src/lib
parent46b81a642e3087476fa3ad74e16750d722addf77 (diff)
downloadopenbsd-129c2cdcfb40e6b942b798ab40091669eac48a9f.tar.gz
openbsd-129c2cdcfb40e6b942b798ab40091669eac48a9f.tar.bz2
openbsd-129c2cdcfb40e6b942b798ab40091669eac48a9f.zip
Use OBJ_cmp() instead of inlining two variants
This also avoids more undefined behavior with memcmp(). ok jsing PS: Unsolicited advice for no one in particular: there is this awesome tool called grep. If someone reports an issue, you might want to use it to find more instances.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index ff06177451..481d86b6bf 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.54 2023/07/08 12:27:51 beck Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.55 2023/08/17 09:18:21 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 *
@@ -188,10 +188,7 @@ added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb)
188 b = cb->obj; 188 b = cb->obj;
189 switch (ca->type) { 189 switch (ca->type) {
190 case ADDED_DATA: 190 case ADDED_DATA:
191 i = (a->length - b->length); 191 return OBJ_cmp(a, b);
192 if (i)
193 return (i);
194 return (memcmp(a->data, b->data, (size_t)a->length));
195 case ADDED_SNAME: 192 case ADDED_SNAME:
196 if (a->sn == NULL) 193 if (a->sn == NULL)
197 return (-1); 194 return (-1);
@@ -432,17 +429,12 @@ LCRYPTO_ALIAS(OBJ_nid2ln);
432static int 429static int
433obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp) 430obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp)
434{ 431{
435 int j; 432 const ASN1_OBJECT *a = *ap;
436 const ASN1_OBJECT *a= *ap;
437 const ASN1_OBJECT *b = &nid_objs[*bp]; 433 const ASN1_OBJECT *b = &nid_objs[*bp];
438 434
439 j = (a->length - b->length); 435 return OBJ_cmp(a, b);
440 if (j)
441 return (j);
442 return (memcmp(a->data, b->data, a->length));
443} 436}
444 437
445
446static int 438static int
447obj_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) 439obj_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
448{ 440{