summaryrefslogtreecommitdiff
path: root/test/param_build_test.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2020-03-27 10:33:46 +1000
committerPauli <paul.dale@oracle.com>2020-03-28 12:27:22 +1000
commit20c98cd45399423f760dbd75d8912769c6b7b10e (patch)
tree6d5005b1925d47baf7343811e6101988a9772b00 /test/param_build_test.c
parent6d4e6009d27712a405e1e3a4c33fb8a8566f134a (diff)
downloadopenssl-new-20c98cd45399423f760dbd75d8912769c6b7b10e.tar.gz
Param builder: Remove the static size limit.
Prior to this, the param builder had a statically sized array internally. This changes it so that it uses a stack instead. Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> (Merged from https://github.com/openssl/openssl/pull/11390)
Diffstat (limited to 'test/param_build_test.c')
-rw-r--r--test/param_build_test.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/param_build_test.c b/test/param_build_test.c
index 9b20e33360..c5fcc70a66 100644
--- a/test/param_build_test.c
+++ b/test/param_build_test.c
@@ -192,9 +192,53 @@ err:
return res;
}
+static int builder_limit_test(void)
+{
+ const int n = 100;
+ char names[100][3];
+ OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new();
+ OSSL_PARAM *params = NULL;
+ int i, res = 0;
+
+ if (!TEST_ptr(bld))
+ goto err;
+
+ for (i = 0; i < n; i++) {
+ names[i][0] = 'A' + (i / 26) - 1;
+ names[i][0] = 'a' + (i % 26) - 1;
+ names[i][2] = '\0';
+ if (!TEST_true(OSSL_PARAM_BLD_push_int(bld, names[i], 3 * i + 1)))
+ goto err;
+ }
+ if (!TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)))
+ goto err;
+ /* Count the elements in the params arrary, expecting n */
+ for (i = 0; params[i].key != NULL; i++);
+ if (!TEST_int_eq(i, n))
+ goto err;
+
+ /* Verify that the build, cleared the builder structure */
+ OSSL_PARAM_BLD_free_params(params);
+ params = NULL;
+
+ if (!TEST_true(OSSL_PARAM_BLD_push_int(bld, "g", 2))
+ || !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)))
+ goto err;
+ /* Count the elements in the params arrary, expecting 1 */
+ for (i = 0; params[i].key != NULL; i++);
+ if (!TEST_int_eq(i, 1))
+ goto err;
+ res = 1;
+err:
+ OSSL_PARAM_BLD_free_params(params);
+ OSSL_PARAM_BLD_free(bld);
+ return res;
+}
+
int setup_tests(void)
{
ADD_TEST(template_public_test);
ADD_TEST(template_private_test);
+ ADD_TEST(builder_limit_test);
return 1;
}