From 6069fece903bbee185f40fb99ad4f37a42a97385 Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 2 Jul 2022 09:33:20 +0000 Subject: [PATCH] Make tls1_ec_curve_id2nid() return explicit NID_undef instead of 0 on error and adjust the only caller that didn't check for NID_undef already. ok beck jsing --- lib/libssl/t1_lib.c | 6 +++--- lib/libssl/tls_key_share.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libssl/t1_lib.c b/lib/libssl/t1_lib.c index 105acf1cbf8..1dca30529d4 100644 --- a/lib/libssl/t1_lib.c +++ b/lib/libssl/t1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_lib.c,v 1.188 2022/06/30 16:18:03 tb Exp $ */ +/* $OpenBSD: t1_lib.c,v 1.189 2022/07/02 09:33:20 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -341,10 +341,10 @@ tls1_ec_curve_id2nid(const uint16_t curve_id) /* ECC curves from draft-ietf-tls-ecc-12.txt (Oct. 17, 2005) */ if ((curve_id < 1) || ((unsigned int)curve_id > sizeof(nid_list) / sizeof(nid_list[0]))) - return 0; + return NID_undef; if ((curve = &nid_list[curve_id]) == NULL) - return 0; + return NID_undef; return curve->nid; } diff --git a/lib/libssl/tls_key_share.c b/lib/libssl/tls_key_share.c index 0b941d8b0d7..c170f086495 100644 --- a/lib/libssl/tls_key_share.c +++ b/lib/libssl/tls_key_share.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_key_share.c,v 1.5 2022/06/29 08:27:52 tb Exp $ */ +/* $OpenBSD: tls_key_share.c,v 1.6 2022/07/02 09:33:20 tb Exp $ */ /* * Copyright (c) 2020, 2021 Joel Sing * @@ -61,7 +61,7 @@ tls_key_share_new(uint16_t group_id) { int nid; - if ((nid = tls1_ec_curve_id2nid(group_id)) == 0) + if ((nid = tls1_ec_curve_id2nid(group_id)) == NID_undef) return NULL; return tls_key_share_new_internal(nid, group_id); -- 2.20.1