summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects/obj_dat.c
diff options
context:
space:
mode:
authorjsing <>2022-02-11 16:39:16 +0000
committerjsing <>2022-02-11 16:39:16 +0000
commit5fce02c42e4ad8d8f3ab223ed16a8fe28d08812f (patch)
tree67a04a9245a78e948c5ef72b79a2846b2f153d0c /src/lib/libcrypto/objects/obj_dat.c
parent027a6370238b481d225c2cd67cc22902b173fb6b (diff)
downloadopenbsd-5fce02c42e4ad8d8f3ab223ed16a8fe28d08812f.tar.gz
openbsd-5fce02c42e4ad8d8f3ab223ed16a8fe28d08812f.tar.bz2
openbsd-5fce02c42e4ad8d8f3ab223ed16a8fe28d08812f.zip
Make OBJ_obj2nid() work correctly with NID_undef.
Currently OBJ_obj2nid() with NID_undef returns NID_ccitt - this is due to doing a lookup on an empty value and having NID_undef conflict with an uninitialised NID value. Somewhat based on OpenSSL 0fb99904809. ok tb@
Diffstat (limited to 'src/lib/libcrypto/objects/obj_dat.c')
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 4f7396f669..7aecda2641 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.45 2022/01/08 21:36:39 tb Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.46 2022/02/11 16:39:16 jsing 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 *
@@ -458,9 +458,9 @@ OBJ_obj2nid(const ASN1_OBJECT *a)
458 const unsigned int *op; 458 const unsigned int *op;
459 ADDED_OBJ ad, *adp; 459 ADDED_OBJ ad, *adp;
460 460
461 if (a == NULL) 461 if (a == NULL || a->length == 0)
462 return (NID_undef); 462 return (NID_undef);
463 if (a->nid != 0) 463 if (a->nid != NID_undef)
464 return (a->nid); 464 return (a->nid);
465 465
466 if (added != NULL) { 466 if (added != NULL) {