From: jsing Date: Fri, 11 Feb 2022 16:39:16 +0000 (+0000) Subject: Make OBJ_obj2nid() work correctly with NID_undef. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0709e0c5b399519580f68aad556b951e95901922;p=openbsd 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@ --- diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c index 4f7396f669b..7aecda2641d 100644 --- a/lib/libcrypto/objects/obj_dat.c +++ b/lib/libcrypto/objects/obj_dat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_dat.c,v 1.45 2022/01/08 21:36:39 tb Exp $ */ +/* $OpenBSD: obj_dat.c,v 1.46 2022/02/11 16:39:16 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -458,9 +458,9 @@ OBJ_obj2nid(const ASN1_OBJECT *a) const unsigned int *op; ADDED_OBJ ad, *adp; - if (a == NULL) + if (a == NULL || a->length == 0) return (NID_undef); - if (a->nid != 0) + if (a->nid != NID_undef) return (a->nid); if (added != NULL) {