diff options
author | jsing <> | 2022-02-11 16:39:16 +0000 |
---|---|---|
committer | jsing <> | 2022-02-11 16:39:16 +0000 |
commit | 72eb47d407399328d04cdeeb77a61013d0ee46d3 (patch) | |
tree | 67a04a9245a78e948c5ef72b79a2846b2f153d0c | |
parent | d4f6b8b800bdd1cc2c6b3c48bb59920e93f1ca77 (diff) | |
download | openbsd-72eb47d407399328d04cdeeb77a61013d0ee46d3.tar.gz openbsd-72eb47d407399328d04cdeeb77a61013d0ee46d3.tar.bz2 openbsd-72eb47d407399328d04cdeeb77a61013d0ee46d3.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@
-rw-r--r-- | src/lib/libcrypto/objects/obj_dat.c | 6 |
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) { |