[openssl] openssl-3.0 update

Dr. Paul Dale pauli at openssl.org
Sat Oct 9 13:31:08 UTC 2021


The branch openssl-3.0 has been updated
       via  c3b89fc770f3e83ddd0976403c1b321496778b38 (commit)
      from  6e3d51ae6826850580138790bcc13ac7c01d7b47 (commit)


- Log -----------------------------------------------------------------
commit c3b89fc770f3e83ddd0976403c1b321496778b38
Author: Pauli <pauli at openssl.org>
Date:   Thu Sep 30 11:35:32 2021 +1000

    test: add failure testing for property parsing
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/16716)
    
    (cherry picked from commit 747d142318c5c9ecd80de3f061f54d7af4189039)

-----------------------------------------------------------------------

Summary of changes:
 test/property_test.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/test/property_test.c b/test/property_test.c
index 6cc8eec138..c23ddb0f99 100644
--- a/test/property_test.c
+++ b/test/property_test.c
@@ -145,6 +145,52 @@ static int test_property_query_value_create(void)
     return r;
 }
 
+static const struct {
+    int query;
+    const char *ps;
+} parse_error_tests[] = {
+    { 0, "n=1, n=1" },          /* duplicate name */
+    { 0, "n=1, a=hi, n=1" },    /* duplicate name */
+    { 1, "n=1, a=bye, ?n=0" },  /* duplicate name */
+    { 0, "a=abc,#@!, n=1" },    /* non-ASCII character located */
+    { 1, "a='Hello" },          /* Unterminated string */
+    { 0, "a=\"World" },         /* Unterminated string */
+    { 1, "a=2, n=012345678" },  /* Bad octal digit */
+    { 0, "n=0x28FG, a=3" },     /* Bad hex digit */
+    { 0, "n=145d, a=2" },       /* Bad decimal digit */
+    { 1, "@='hello'" },         /* Invalid name */
+    { 1, "n0123456789012345678901234567890123456789"
+         "0123456789012345678901234567890123456789"
+         "0123456789012345678901234567890123456789"
+         "0123456789012345678901234567890123456789=yes" }, /* Name too long */
+    { 0, ".n=3" },              /* Invalid name */
+    { 1, "fnord.fnord.=3" }     /* Invalid name */
+};
+
+static int test_property_parse_error(int n)
+{
+    OSSL_METHOD_STORE *store;
+    OSSL_PROPERTY_LIST *p = NULL;
+    int r = 0;
+    const char *ps;
+
+    if (!TEST_ptr(store = ossl_method_store_new(NULL))
+        || !add_property_names("a", "n", NULL))
+        goto err;
+    ps = parse_error_tests[n].ps;
+    if (parse_error_tests[n].query) {
+        if (!TEST_ptr_null(p = ossl_parse_query(NULL, ps, 1)))
+            goto err;
+    } else if (!TEST_ptr_null(p = ossl_parse_property(NULL, ps))) {
+        goto err;
+    }
+    r = 1;
+ err:
+    ossl_property_free(p);
+    ossl_method_store_free(store);
+    return r;
+}
+
 static const struct {
     const char *q_global;
     const char *q_local;
@@ -493,6 +539,7 @@ int setup_tests(void)
     ADD_TEST(test_property_string);
     ADD_TEST(test_property_query_value_create);
     ADD_ALL_TESTS(test_property_parse, OSSL_NELEM(parser_tests));
+    ADD_ALL_TESTS(test_property_parse_error, OSSL_NELEM(parse_error_tests));
     ADD_ALL_TESTS(test_property_merge, OSSL_NELEM(merge_tests));
     ADD_TEST(test_property_defn_cache);
     ADD_ALL_TESTS(test_definition_compares, OSSL_NELEM(definition_tests));


More information about the openssl-commits mailing list