From e751c109d68602b75cc6b8e0f9f3a128354aaad5 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Tue, 9 Jan 2024 15:05:30 +0100 Subject: [PATCH] Fix a similar memory leak in SXNET_add_id_INTEGER Even in the good case there was memory leak here. Add a simple test case to have at least some test coverage. Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/23234) (cherry picked from commit 398011848468c7e8e481b295f7904afc30934217) --- crypto/x509/v3_sxnet.c | 1 + test/recipes/25-test_req.t | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/x509/v3_sxnet.c b/crypto/x509/v3_sxnet.c index 56deece2fd0..0ad2a3f939d 100644 --- a/crypto/x509/v3_sxnet.c +++ b/crypto/x509/v3_sxnet.c @@ -196,6 +196,7 @@ int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *zone, const char *user, goto err; if (!sk_SXNETID_push(sx->ids, id)) goto err; + ASN1_INTEGER_free(id->zone); id->zone = zone; *psx = sx; return 1; diff --git a/test/recipes/25-test_req.t b/test/recipes/25-test_req.t index f9158ed751d..c63b786de79 100644 --- a/test/recipes/25-test_req.t +++ b/test/recipes/25-test_req.t @@ -15,7 +15,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/; setup("test_req"); -plan tests => 48; +plan tests => 49; require_ok(srctop_file('test', 'recipes', 'tconversion.pl')); @@ -52,6 +52,7 @@ ok(!run(app([@addext_args, "-addext", $val, "-addext", $val]))); ok(!run(app([@addext_args, "-addext", $val, "-addext", $val2]))); ok(!run(app([@addext_args, "-addext", $val, "-addext", $val3]))); ok(!run(app([@addext_args, "-addext", $val2, "-addext", $val3]))); +ok(run(app([@addext_args, "-addext", "SXNetID=1:one, 2:two, 3:three"]))); # If a CSR is provided with neither of -key or -CA/-CAkey, this should fail. ok(!run(app(["openssl", "req", "-x509", -- 2.47.2