diff options
author | Hugo Landau <hlandau@openssl.org> | 2022-03-03 17:27:23 +0000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-03-11 13:30:22 +1100 |
commit | add8c29badb315cb8137655893826562ff12a581 (patch) | |
tree | 3de7cb5097e4f277bac157c4e814f083956ae721 /test | |
parent | 3aeed22c593ae036c2503ac07276768c82fe5782 (diff) |
Fix issue where OBJ_nid2obj doesn't always raise an error
This was previously fixed in 3.0 but not 1.1.
Fixes #13008.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17808)
Diffstat (limited to 'test')
-rw-r--r-- | test/asn1_internal_test.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/asn1_internal_test.c b/test/asn1_internal_test.c index 865e058421..caca0cb15e 100644 --- a/test/asn1_internal_test.c +++ b/test/asn1_internal_test.c @@ -107,9 +107,36 @@ static int test_standard_methods(void) return 0; } +/********************************************************************** + * + * Regression test for issue where OBJ_nid2obj does not raise + * an error when a NID is not registered. + * + ***/ +static int test_nid2obj_nonexist(void) +{ + ASN1_OBJECT *obj; + unsigned long err; + + obj = OBJ_nid2obj(INT_MAX); + if (!TEST_true(obj == NULL)) + return 0; + + err = ERR_get_error(); + + if (!TEST_int_eq(ERR_GET_FUNC(err), OBJ_F_OBJ_NID2OBJ)) + return 0; + + if (!TEST_int_eq(ERR_GET_REASON(err), OBJ_R_UNKNOWN_NID)) + return 0; + + return 1; +} + int setup_tests(void) { ADD_TEST(test_tbl_standard); ADD_TEST(test_standard_methods); + ADD_TEST(test_nid2obj_nonexist); return 1; } |