test/property_test.c:243: error: BUFFER_OVERRUN_L3
  Offset added: [1, 11] Size: [0, +oo] by call to `ossl_method_store_add`.
Showing all 10 steps of the trace


test/property_test.c:229:9: Array declaration
227.           char *impl;
228.       } impls[] = {
229.           { 6, "position=1", "a" },
               ^
230.           { 6, "position=2", "b" },
231.           { 6, "position=3", "c" },

test/property_test.c:243:14: Call
241.   
242.       for (i = 0; i < OSSL_NELEM(impls); i++)
243.           if (!TEST_true(ossl_method_store_add(store, NULL, impls[i].nid,
                    ^
244.                                                impls[i].prop, impls[i].impl,
245.                                                NULL, NULL))) {

crypto/property/property.c:177:1: Parameter `*properties`
  175.   }
  176.   
  177. > int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov,
  178.                             int nid, const char *properties, void *method,
  179.                             int (*method_up_ref)(void *),

crypto/property/property.c:216:9: Call
  214.           if (impl->properties == NULL)
  215.               goto err;
  216.           ossl_prop_defn_set(store->ctx, properties, impl->properties);
                 ^
  217.       }
  218.   

crypto/property/defn_cache.c:84:1: <Offset trace>
82.   }
83.   
84. > int ossl_prop_defn_set(OPENSSL_CTX *ctx, const char *prop,
85.                          OSSL_PROPERTY_LIST *pl)
86.   {

crypto/property/defn_cache.c:84:1: Parameter `prop->strlen`
    82.   }
    83.   
    84. > int ossl_prop_defn_set(OPENSSL_CTX *ctx, const char *prop,
    85.                          OSSL_PROPERTY_LIST *pl)
    86.   {

crypto/property/defn_cache.c:104:5: Assignment
    102.           return 1;
    103.       }
    104.       len = strlen(prop);
               ^
    105.       p = OPENSSL_malloc(sizeof(*p) + len);
    106.       if (p != NULL) {

crypto/property/defn_cache.c:84:1: <Length trace>
82.   }
83.   
84. > int ossl_prop_defn_set(OPENSSL_CTX *ctx, const char *prop,
85.                          OSSL_PROPERTY_LIST *pl)
86.   {

crypto/property/defn_cache.c:84:1: Parameter `*prop`
    82.   }
    83.   
    84. > int ossl_prop_defn_set(OPENSSL_CTX *ctx, const char *prop,
    85.                          OSSL_PROPERTY_LIST *pl)
    86.   {

crypto/property/defn_cache.c:109:9: Array access: Offset added: [1, 11] Size: [0, +oo] by call to `ossl_method_store_add` 
    107.           p->prop = p->body;
    108.           p->defn = pl;
    109.           memcpy(p->body, prop, len + 1);
                   ^
    110.           old = lh_PROPERTY_DEFN_ELEM_insert(property_defns, p);
    111.           if (old != NULL) {

int ossl_prop_defn_set(OPENSSL_CTX *ctx, const char *prop,
                       OSSL_PROPERTY_LIST *pl)
{
    PROPERTY_DEFN_ELEM elem, *old, *p = NULL;
    size_t len;
    LHASH_OF(PROPERTY_DEFN_ELEM) *property_defns;
    property_defns = openssl_ctx_get_data(ctx, OPENSSL_CTX_PROPERTY_DEFN_INDEX,
                                          &property_defns_method);
    if (property_defns == NULL)
        return 0;
    if (prop == NULL)
        return 1;
    if (pl == NULL) {
        elem.prop = prop;
        lh_PROPERTY_DEFN_ELEM_delete(property_defns, &elem);
        return 1;
    }
    len = strlen(prop);
    p = OPENSSL_malloc(sizeof(*p) + len);
    if (p != NULL) {
        p->prop = p->body;
        p->defn = pl;
        memcpy(p->body, prop, len + 1);
        old = lh_PROPERTY_DEFN_ELEM_insert(property_defns, p);
        if (old != NULL) {
            property_defn_free(old);
            return 1;
        }
        if (!lh_PROPERTY_DEFN_ELEM_error(property_defns))
            return 1;
    }
    OPENSSL_free(p);
    return 0;
}
['static int test_register_deregister(void)\n{\n    static const struct {\n        int nid;\n        const char *prop;\n        char *impl;\n    } impls[] = {\n        { 6, "position=1", "a" },\n        { 6, "position=2", "b" },\n        { 6, "position=3", "c" },\n        { 6, "position=4", "d" },\n    };\n    size_t i;\n    int ret = 0;\n    OSSL_METHOD_STORE *store;\n    if (!TEST_ptr(store = ossl_method_store_new(NULL))\n        || !add_property_names("position", NULL))\n        goto err;\n    for (i = 0; i < OSSL_NELEM(impls); i++)\n        if (!TEST_true(ossl_method_store_add(store, NULL, impls[i].nid,\n                                             impls[i].prop, impls[i].impl,\n                                             NULL, NULL))) {\n            TEST_note("iteration %zd", i + 1);\n            goto err;\n        }\n    for (i = 0; i < OSSL_NELEM(impls); i++) {\n        const size_t j = (1 + i * 3) % OSSL_NELEM(impls);\n        int nid = impls[j].nid;\n        void *impl = impls[j].impl;\n        if (!TEST_true(ossl_method_store_remove(store, nid, impl))\n            || !TEST_false(ossl_method_store_remove(store, nid, impl))) {\n            TEST_note("iteration %zd, position %zd", i + 1, j + 1);\n            goto err;\n        }\n    }\n    if (TEST_false(ossl_method_store_remove(store, impls[0].nid, impls[0].impl)))\n        ret = 1;\nerr:\n    ossl_method_store_free(store);\n    return ret;\n}', 'int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov,\n                          int nid, const char *properties, void *method,\n                          int (*method_up_ref)(void *),\n                          void (*method_destruct)(void *))\n{\n    ALGORITHM *alg = NULL;\n    IMPLEMENTATION *impl;\n    int ret = 0;\n    int i;\n    if (nid <= 0 || method == NULL || store == NULL)\n        return 0;\n    if (properties == NULL)\n        properties = "";\n    impl = OPENSSL_malloc(sizeof(*impl));\n    if (impl == NULL)\n        return 0;\n    if (method_up_ref != NULL && !method_up_ref(method)) {\n        OPENSSL_free(impl);\n        return 0;\n    }\n    impl->provider = prov;\n    impl->method = method;\n    impl->method_destruct = method_destruct;\n    ossl_property_write_lock(store);\n    ossl_method_cache_flush(store, nid);\n    if ((impl->properties = ossl_prop_defn_get(store->ctx, properties)) == NULL) {\n        impl->properties = ossl_parse_property(store->ctx, properties);\n        if (impl->properties == NULL)\n            goto err;\n        ossl_prop_defn_set(store->ctx, properties, impl->properties);\n    }\n    alg = ossl_method_store_retrieve(store, nid);\n    if (alg == NULL) {\n        if ((alg = OPENSSL_zalloc(sizeof(*alg))) == NULL\n                || (alg->impls = sk_IMPLEMENTATION_new_null()) == NULL\n                || (alg->cache = lh_QUERY_new(&query_hash, &query_cmp)) == NULL)\n            goto err;\n        alg->nid = nid;\n        if (!ossl_method_store_insert(store, alg))\n            goto err;\n    }\n    for (i = 0; i < sk_IMPLEMENTATION_num(alg->impls); i++) {\n        const IMPLEMENTATION *tmpimpl = sk_IMPLEMENTATION_value(alg->impls, i);\n        if (tmpimpl->provider == impl->provider\n            && tmpimpl->properties == impl->properties)\n            break;\n    }\n    if (i == sk_IMPLEMENTATION_num(alg->impls)\n        && sk_IMPLEMENTATION_push(alg->impls, impl))\n        ret = 1;\n    ossl_property_unlock(store);\n    if (ret == 0)\n        impl_free(impl);\n    return ret;\nerr:\n    ossl_property_unlock(store);\n    alg_cleanup(0, alg);\n    impl_free(impl);\n    return 0;\n}', 'int ossl_prop_defn_set(OPENSSL_CTX *ctx, const char *prop,\n                       OSSL_PROPERTY_LIST *pl)\n{\n    PROPERTY_DEFN_ELEM elem, *old, *p = NULL;\n    size_t len;\n    LHASH_OF(PROPERTY_DEFN_ELEM) *property_defns;\n    property_defns = openssl_ctx_get_data(ctx, OPENSSL_CTX_PROPERTY_DEFN_INDEX,\n                                          &property_defns_method);\n    if (property_defns == NULL)\n        return 0;\n    if (prop == NULL)\n        return 1;\n    if (pl == NULL) {\n        elem.prop = prop;\n        lh_PROPERTY_DEFN_ELEM_delete(property_defns, &elem);\n        return 1;\n    }\n    len = strlen(prop);\n    p = OPENSSL_malloc(sizeof(*p) + len);\n    if (p != NULL) {\n        p->prop = p->body;\n        p->defn = pl;\n        memcpy(p->body, prop, len + 1);\n        old = lh_PROPERTY_DEFN_ELEM_insert(property_defns, p);\n        if (old != NULL) {\n            property_defn_free(old);\n            return 1;\n        }\n        if (!lh_PROPERTY_DEFN_ELEM_error(property_defns))\n            return 1;\n    }\n    OPENSSL_free(p);\n    return 0;\n}']