test/property_test.c:350: error: BUFFER_OVERRUN_L3
  Offset: [2, +oo] (⇐ [1, +oo] + 1) Size: [1, 50] by call to `ossl_method_store_add`.
Showing all 23 steps of the trace


test/property_test.c:333:1: Array declaration
331.   }
332.   
333. > static int test_query_cache_stochastic(void)
334.   {
335.       const int max = 10000, tail = 10;

test/property_test.c:350:14: Call
348.           v[i] = 2 * i;
349.           BIO_snprintf(buf, sizeof(buf), "n=%d\n", i);
350.           if (!TEST_true(ossl_method_store_add(store, i, buf, "abc", NULL))
                    ^
351.                   || !TEST_true(ossl_method_store_cache_set(store, i, buf, v + i))
352.                   || !TEST_true(ossl_method_store_cache_set(store, i, "n=1234",

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

crypto/property/property.c:205:28: Call
  203.       ossl_method_cache_flush(store, nid);
  204.       if ((impl->properties = ossl_prop_defn_get(store->ctx, properties)) == NULL) {
  205.           impl->properties = ossl_parse_property(store->ctx, properties);
                                    ^
  206.           if (impl->properties == NULL)
  207.               goto err;

crypto/property/property_parse.c:336:1: Parameter `*defn`
    334.   }
    335.   
    336. > OSSL_PROPERTY_LIST *ossl_parse_property(OPENSSL_CTX *ctx, const char *defn)
    337.   {
    338.       PROPERTY_DEFINITION *prop = NULL;

crypto/property/property_parse.c:341:5: Assignment
    339.       OSSL_PROPERTY_LIST *res = NULL;
    340.       STACK_OF(PROPERTY_DEFINITION) *sk;
    341.       const char *s = defn;
               ^
    342.       int done;
    343.   

crypto/property/property_parse.c:347:9: Call
    345.           return NULL;
    346.   
    347.       s = skip_space(s);
                   ^
    348.       done = *s == '\0';
    349.       while (!done) {

crypto/property/property_parse.c:52:1: Parameter `*s`
      50.   DEFINE_STACK_OF(PROPERTY_DEFINITION)
      51.   
      52. > static const char *skip_space(const char *s)
      53.   {
      54.       while (ossl_isspace(*s))

crypto/property/property_parse.c:56:5: Assignment
      54.       while (ossl_isspace(*s))
      55.           s++;
      56.       return s;
                ^
      57.   }
      58.   

crypto/property/property_parse.c:347:5: Assignment
    345.           return NULL;
    346.   
    347.       s = skip_space(s);
               ^
    348.       done = *s == '\0';
    349.       while (!done) {

crypto/property/property_parse.c:357:14: Call
    355.           memset(&prop->v, 0, sizeof(prop->v));
    356.           prop->optional = 0;
    357.           if (!parse_name(ctx, &s, 1, &prop->name_idx))
                        ^
    358.               goto err;
    359.           prop->oper = PROPERTY_OPER_EQ;

crypto/property/property_parse.c:83:1: Parameter `**t`
      81.   }
      82.   
      83. > static int parse_name(OPENSSL_CTX *ctx, const char *t[], int create,
      84.                         OSSL_PROPERTY_IDX *idx)
      85.   {

crypto/property/property_parse.c:365:13: Call
    363.               goto err;
    364.           }
    365.           if (match_ch(&s, '=')) {
                       ^
    366.               if (!parse_value(ctx, &s, prop, 1)) {
    367.                   PROPerr(PROP_F_OSSL_PARSE_PROPERTY, PROP_R_NO_VALUE);

crypto/property/property_parse.c:59:1: Parameter `**t`
      57.   }
      58.   
      59. > static int match_ch(const char *t[], char m)
      60.   {
      61.       const char *s = *t;

crypto/property/property_parse.c:366:18: Call
    364.           }
    365.           if (match_ch(&s, '=')) {
    366.               if (!parse_value(ctx, &s, prop, 1)) {
                            ^
    367.                   PROPerr(PROP_F_OSSL_PARSE_PROPERTY, PROP_R_NO_VALUE);
    368.                   ERR_add_error_data(2, "HERE-->", start);

crypto/property/property_parse.c:261:1: Parameter `**t`
      259.   }
      260.   
      261. > static int parse_value(OPENSSL_CTX *ctx, const char *t[],
      262.                          PROPERTY_DEFINITION *res, int create)
      263.   {

crypto/property/property_parse.c:264:5: Assignment
      262.                          PROPERTY_DEFINITION *res, int create)
      263.   {
      264.       const char *s = *t;
                 ^
      265.       int r = 0;
      266.   

crypto/property/property_parse.c:281:9: Assignment
      279.           r = parse_hex(&s, res);
      280.       } else if (*s == '0' && ossl_isdigit(s[1])) {
      281.           s++;
                     ^
      282.           r = parse_oct(&s, res);
      283.       } else if (ossl_isdigit(*s)) {

crypto/property/property_parse.c:282:13: Call
      280.       } else if (*s == '0' && ossl_isdigit(s[1])) {
      281.           s++;
      282.           r = parse_oct(&s, res);
                         ^
      283.       } else if (ossl_isdigit(*s)) {
      284.           return parse_number(t, res);

crypto/property/property_parse.c:170:1: <Length trace>
168.   }
169.   
170. > static int parse_oct(const char *t[], PROPERTY_DEFINITION *res)
171.   {
172.       const char *s = *t;

crypto/property/property_parse.c:170:1: Parameter `**t`
        168.   }
        169.   
        170. > static int parse_oct(const char *t[], PROPERTY_DEFINITION *res)
        171.   {
        172.       const char *s = *t;

crypto/property/property_parse.c:172:5: Assignment
        170.   static int parse_oct(const char *t[], PROPERTY_DEFINITION *res)
        171.   {
        172.       const char *s = *t;
                   ^
        173.       int64_t v = 0;
        174.   

crypto/property/property_parse.c:179:14: Array access: Offset: [2, +oo] (⇐ [1, +oo] + 1) Size: [1, 50] by call to `ossl_method_store_add` 
        177.       do {
        178.           v = (v << 3) + (*s - '0');
        179.       } while (ossl_isdigit(*++s) && *s != '9' && *s != '8');
                            ^
        180.       if (!ossl_isspace(*s) && *s != '\0' && *s != ',') {
        181.           PROPerr(PROP_F_PARSE_OCT, PROP_R_NOT_AN_OCTAL_DIGIT);

static int parse_oct(const char *t[], PROPERTY_DEFINITION *res)
{
    const char *s = *t;
    int64_t v = 0;
    if (*s == '9' || *s == '8' || !ossl_isdigit(*s))
        return 0;
    do {
        v = (v << 3) + (*s - '0');
    } while (ossl_isdigit(*++s) && *s != '9' && *s != '8');
    if (!ossl_isspace(*s) && *s != '\0' && *s != ',') {
        PROPerr(PROP_F_PARSE_OCT, PROP_R_NOT_AN_OCTAL_DIGIT);
        ERR_add_error_data(2, "HERE-->", *t);
        return 0;
    }
    *t = skip_space(s);
    res->type = PROPERTY_TYPE_NUMBER;
    res->v.int_val = v;
    return 1;
}
['static int test_query_cache_stochastic(void)\n{\n    const int max = 10000, tail = 10;\n    OSSL_METHOD_STORE *store;\n    int i, res = 0;\n    char buf[50];\n    void *result;\n    int errors = 0;\n    int v[10001];\n    if (!TEST_ptr(store = ossl_method_store_new(NULL))\n        || !add_property_names("n", NULL))\n        goto err;\n    for (i = 1; i <= max; i++) {\n        v[i] = 2 * i;\n        BIO_snprintf(buf, sizeof(buf), "n=%d\\n", i);\n        if (!TEST_true(ossl_method_store_add(store, i, buf, "abc", NULL))\n                || !TEST_true(ossl_method_store_cache_set(store, i, buf, v + i))\n                || !TEST_true(ossl_method_store_cache_set(store, i, "n=1234",\n                                                          "miss"))) {\n            TEST_note("iteration %d", i);\n            goto err;\n        }\n    }\n    for (i = 1; i <= max; i++) {\n        BIO_snprintf(buf, sizeof(buf), "n=%d\\n", i);\n        if (!ossl_method_store_cache_get(store, i, buf, &result)\n            || result != v + i)\n            errors++;\n    }\n    res = TEST_int_gt(errors, tail) && TEST_int_lt(errors, max - tail);\nerr:\n    ossl_method_store_free(store);\n    return res;\n}', 'int ossl_method_store_add(OSSL_METHOD_STORE *store,\n                          int nid, const char *properties,\n                          void *method, void (*method_destruct)(void *))\n{\n    ALGORITHM *alg = NULL;\n    IMPLEMENTATION *impl;\n    int ret = 0;\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    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    if (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}', 'OSSL_PROPERTY_LIST *ossl_parse_property(OPENSSL_CTX *ctx, const char *defn)\n{\n    PROPERTY_DEFINITION *prop = NULL;\n    OSSL_PROPERTY_LIST *res = NULL;\n    STACK_OF(PROPERTY_DEFINITION) *sk;\n    const char *s = defn;\n    int done;\n    if (s == NULL || (sk = sk_PROPERTY_DEFINITION_new(&pd_compare)) == NULL)\n        return NULL;\n    s = skip_space(s);\n    done = *s == \'\\0\';\n    while (!done) {\n        const char *start = s;\n        prop = OPENSSL_malloc(sizeof(*prop));\n        if (prop == NULL)\n            goto err;\n        memset(&prop->v, 0, sizeof(prop->v));\n        prop->optional = 0;\n        if (!parse_name(ctx, &s, 1, &prop->name_idx))\n            goto err;\n        prop->oper = PROPERTY_OPER_EQ;\n        if (prop->name_idx == 0) {\n            PROPerr(PROP_F_OSSL_PARSE_PROPERTY, PROP_R_PARSE_FAILED);\n            ERR_add_error_data(2, "Unknown name HERE-->", start);\n            goto err;\n        }\n        if (match_ch(&s, \'=\')) {\n            if (!parse_value(ctx, &s, prop, 1)) {\n                PROPerr(PROP_F_OSSL_PARSE_PROPERTY, PROP_R_NO_VALUE);\n                ERR_add_error_data(2, "HERE-->", start);\n                goto err;\n            }\n        } else {\n            prop->type = PROPERTY_TYPE_STRING;\n            prop->v.str_val = ossl_property_true;\n        }\n        if (!sk_PROPERTY_DEFINITION_push(sk, prop))\n            goto err;\n        prop = NULL;\n        done = !match_ch(&s, \',\');\n    }\n    if (*s != \'\\0\') {\n        PROPerr(PROP_F_OSSL_PARSE_PROPERTY, PROP_R_TRAILING_CHARACTERS);\n        ERR_add_error_data(2, "HERE-->", s);\n        goto err;\n    }\n    res = stack_to_property_list(sk);\nerr:\n    OPENSSL_free(prop);\n    sk_PROPERTY_DEFINITION_pop_free(sk, &pd_free);\n    return res;\n}', 'static const char *skip_space(const char *s)\n{\n    while (ossl_isspace(*s))\n        s++;\n    return s;\n}', 'static int parse_name(OPENSSL_CTX *ctx, const char *t[], int create,\n                      OSSL_PROPERTY_IDX *idx)\n{\n    char name[100];\n    int err = 0;\n    size_t i = 0;\n    const char *s = *t;\n    int user_name = 0;\n    for (;;) {\n        if (!ossl_isalpha(*s)) {\n            PROPerr(PROP_F_PARSE_NAME, PROP_R_NOT_AN_IDENTIFIER);\n            ERR_add_error_data(2, "HERE-->", *t);\n            return 0;\n        }\n        do {\n            if (i < sizeof(name) - 1)\n                name[i++] = ossl_tolower(*s);\n            else\n                err = 1;\n        } while (*++s == \'_\' || ossl_isalnum(*s));\n        if (*s != \'.\')\n            break;\n        user_name = 1;\n        if (i < sizeof(name) - 1)\n            name[i++] = *s;\n        else\n            err = 1;\n        s++;\n    }\n    name[i] = \'\\0\';\n    if (err) {\n        PROPerr(PROP_F_PARSE_NAME, PROP_R_NAME_TOO_LONG);\n        ERR_add_error_data(2, "HERE-->", *t);\n        return 0;\n    }\n    *t = skip_space(s);\n    *idx = ossl_property_name(ctx, name, user_name && create);\n    return 1;\n}', 'static int match_ch(const char *t[], char m)\n{\n    const char *s = *t;\n    if (*s == m) {\n        *t = skip_space(s + 1);\n        return 1;\n    }\n    return 0;\n}', 'static int parse_value(OPENSSL_CTX *ctx, const char *t[],\n                       PROPERTY_DEFINITION *res, int create)\n{\n    const char *s = *t;\n    int r = 0;\n    if (*s == \'"\' || *s == \'\\\'\') {\n        s++;\n        r = parse_string(ctx, &s, s[-1], res, create);\n    } else if (*s == \'+\') {\n        s++;\n        r = parse_number(&s, res);\n    } else if (*s == \'-\') {\n        s++;\n        r = parse_number(&s, res);\n        res->v.int_val = -res->v.int_val;\n    } else if (*s == \'0\' && s[1] == \'x\') {\n        s += 2;\n        r = parse_hex(&s, res);\n    } else if (*s == \'0\' && ossl_isdigit(s[1])) {\n        s++;\n        r = parse_oct(&s, res);\n    } else if (ossl_isdigit(*s)) {\n        return parse_number(t, res);\n    } else if (ossl_isalpha(*s))\n        return parse_unquoted(ctx, t, res, create);\n    if (r)\n        *t = s;\n    return r;\n}', 'static int parse_oct(const char *t[], PROPERTY_DEFINITION *res)\n{\n    const char *s = *t;\n    int64_t v = 0;\n    if (*s == \'9\' || *s == \'8\' || !ossl_isdigit(*s))\n        return 0;\n    do {\n        v = (v << 3) + (*s - \'0\');\n    } while (ossl_isdigit(*++s) && *s != \'9\' && *s != \'8\');\n    if (!ossl_isspace(*s) && *s != \'\\0\' && *s != \',\') {\n        PROPerr(PROP_F_PARSE_OCT, PROP_R_NOT_AN_OCTAL_DIGIT);\n        ERR_add_error_data(2, "HERE-->", *t);\n        return 0;\n    }\n    *t = skip_space(s);\n    res->type = PROPERTY_TYPE_NUMBER;\n    res->v.int_val = v;\n    return 1;\n}']