test/ecdsatest.c:144: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_dec2bn`.
Showing all 13 steps of the trace


test/ecdsatest.c:127:10: Call
125.   
126.       /* create the key */
127.       if (!TEST_ptr(key = EC_KEY_new_by_curve_name(nid)))
                ^
128.           goto x962_int_err;
129.       use_fake = 1;

crypto/ec/ec_key.c:25:19: Call
  23.   EC_KEY *EC_KEY_new_by_curve_name(int nid)
  24.   {
  25.       EC_KEY *ret = EC_KEY_new();
                          ^
  26.       if (ret == NULL)
  27.           return NULL;

crypto/ec/ec_key.c:20:12: Call
    18.   EC_KEY *EC_KEY_new(void)
    19.   {
    20.       return EC_KEY_new_method(NULL);
                     ^
    21.   }
    22.   

crypto/ec/ec_kmeth.c:123:5: Call
      121.   
      122.   err:
      123.       EC_KEY_free(ret);
                 ^
      124.       return NULL;
      125.   }

crypto/ec/ec_key.c:41:1: Parameter `r->priv_key->d`
        39.   }
        40.   
        41. > void EC_KEY_free(EC_KEY *r)
        42.   {
        43.       int i;

test/ecdsatest.c:144:10: Call
142.       if (!TEST_ptr(r = BN_new()) || !TEST_ptr(s = BN_new()))
143.           goto x962_int_err;
144.       if (!TEST_true(BN_dec2bn(&r, r_in)) || !TEST_true(BN_dec2bn(&s, s_in)))
                ^
145.           goto x962_int_err;
146.       ECDSA_SIG_get0(signature, &sig_r, &sig_s);

crypto/bn/bn_print.c:199:1: Parameter `*(*bn)->d`
  197.   }
  198.   
  199. > int BN_dec2bn(BIGNUM **bn, const char *a)
  200.   {
  201.       BIGNUM *ret = NULL;

crypto/bn/bn_print.c:232:9: Call
  230.       } else {
  231.           ret = *bn;
  232.           BN_zero(ret);
                 ^
  233.       }
  234.   

crypto/bn/bn_lib.c:358:1: <Length trace>
356.   }
357.   
358. > int BN_set_word(BIGNUM *a, BN_ULONG w)
359.   {
360.       bn_check_top(a);

crypto/bn/bn_lib.c:358:1: Parameter `*a->d`
    356.   }
    357.   
    358. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    359.   {
    360.       bn_check_top(a);

crypto/bn/bn_lib.c:361:9: Call
    359.   {
    360.       bn_check_top(a);
    361.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    362.           return 0;
    363.       a->neg = 0;

crypto/bn/bn_lcl.h:660:1: Parameter `*a->d`
      658.                            const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
      659.   
      660. > static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
      661.   {
      662.       if (bits > (INT_MAX - BN_BITS2 + 1))

crypto/bn/bn_lib.c:364:5: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_dec2bn` 
    362.           return 0;
    363.       a->neg = 0;
    364.       a->d[0] = w;
               ^
    365.       a->top = (w ? 1 : 0);
    366.       a->flags &= ~BN_FLG_FIXED_TOP;

int BN_set_word(BIGNUM *a, BN_ULONG w)
{
    bn_check_top(a);
    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
        return 0;
    a->neg = 0;
    a->d[0] = w;
    a->top = (w ? 1 : 0);
    a->flags &= ~BN_FLG_FIXED_TOP;
    bn_check_top(a);
    return 1;
}
['static int x9_62_test_internal(int nid, const char *r_in, const char *s_in)\n{\n    int ret = 0;\n    const char message[] = "abc";\n    unsigned char digest[20];\n    unsigned int dgst_len = 0;\n    EVP_MD_CTX *md_ctx;\n    EC_KEY *key = NULL;\n    ECDSA_SIG *signature = NULL;\n    BIGNUM *r = NULL, *s = NULL;\n    BIGNUM *kinv = NULL, *rp = NULL;\n    const BIGNUM *sig_r, *sig_s;\n    if (!TEST_ptr(md_ctx = EVP_MD_CTX_new()))\n        goto x962_int_err;\n    if (!TEST_true(EVP_DigestInit(md_ctx, EVP_sha1()))\n        || !TEST_true(EVP_DigestUpdate(md_ctx, (const void *)message, 3))\n        || !TEST_true(EVP_DigestFinal(md_ctx, digest, &dgst_len)))\n        goto x962_int_err;\n    TEST_info("testing %s", OBJ_nid2sn(nid));\n    if (!TEST_ptr(key = EC_KEY_new_by_curve_name(nid)))\n        goto x962_int_err;\n    use_fake = 1;\n    if (!TEST_true(EC_KEY_generate_key(key)))\n        goto x962_int_err;\n    use_fake = 1;\n    if (!TEST_true(ECDSA_sign_setup(key, NULL, &kinv, &rp)))\n        goto x962_int_err;\n    if (!TEST_ptr(signature = ECDSA_do_sign_ex(digest, 20, kinv, rp, key)))\n        goto x962_int_err;\n    if (!TEST_ptr(r = BN_new()) || !TEST_ptr(s = BN_new()))\n        goto x962_int_err;\n    if (!TEST_true(BN_dec2bn(&r, r_in)) || !TEST_true(BN_dec2bn(&s, s_in)))\n        goto x962_int_err;\n    ECDSA_SIG_get0(signature, &sig_r, &sig_s);\n    if (!TEST_BN_eq(sig_r, r)\n            || !TEST_BN_eq(sig_s, s))\n        goto x962_int_err;\n    if (!TEST_int_eq(ECDSA_do_verify(digest, 20, signature, key), 1))\n        goto x962_int_err;\n    ret = 1;\n x962_int_err:\n    EC_KEY_free(key);\n    ECDSA_SIG_free(signature);\n    BN_free(r);\n    BN_free(s);\n    EVP_MD_CTX_free(md_ctx);\n    BN_clear_free(kinv);\n    BN_clear_free(rp);\n    return ret;\n}', 'EC_KEY *EC_KEY_new_by_curve_name(int nid)\n{\n    EC_KEY *ret = EC_KEY_new();\n    if (ret == NULL)\n        return NULL;\n    ret->group = EC_GROUP_new_by_curve_name(nid);\n    if (ret->group == NULL) {\n        EC_KEY_free(ret);\n        return NULL;\n    }\n    if (ret->meth->set_group != NULL\n        && ret->meth->set_group(ret, ret->group) == 0) {\n        EC_KEY_free(ret);\n        return NULL;\n    }\n    return ret;\n}', 'EC_KEY *EC_KEY_new(void)\n{\n    return EC_KEY_new_method(NULL);\n}', 'EC_KEY *EC_KEY_new_method(ENGINE *engine)\n{\n    EC_KEY *ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    ret->references = 1;\n    ret->lock = CRYPTO_THREAD_lock_new();\n    if (ret->lock == NULL) {\n        ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(ret);\n        return NULL;\n    }\n    ret->meth = EC_KEY_get_default_method();\n#ifndef OPENSSL_NO_ENGINE\n    if (engine != NULL) {\n        if (!ENGINE_init(engine)) {\n            ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_ENGINE_LIB);\n            goto err;\n        }\n        ret->engine = engine;\n    } else\n        ret->engine = ENGINE_get_default_EC();\n    if (ret->engine != NULL) {\n        ret->meth = ENGINE_get_EC(ret->engine);\n        if (ret->meth == NULL) {\n            ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_ENGINE_LIB);\n            goto err;\n        }\n    }\n#endif\n    ret->version = 1;\n    ret->conv_form = POINT_CONVERSION_UNCOMPRESSED;\n    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_EC_KEY, ret, &ret->ex_data)) {\n        goto err;\n    }\n    if (ret->meth->init != NULL && ret->meth->init(ret) == 0) {\n        ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_INIT_FAIL);\n        goto err;\n    }\n    return ret;\nerr:\n    EC_KEY_free(ret);\n    return NULL;\n}', 'void EC_KEY_free(EC_KEY *r)\n{\n    int i;\n    if (r == NULL)\n        return;\n    CRYPTO_DOWN_REF(&r->references, &i, r->lock);\n    REF_PRINT_COUNT("EC_KEY", r);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    if (r->meth->finish != NULL)\n        r->meth->finish(r);\n#ifndef OPENSSL_NO_ENGINE\n    ENGINE_finish(r->engine);\n#endif\n    if (r->group && r->group->meth->keyfinish)\n        r->group->meth->keyfinish(r);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_EC_KEY, r, &r->ex_data);\n    CRYPTO_THREAD_lock_free(r->lock);\n    EC_GROUP_free(r->group);\n    EC_POINT_free(r->pub_key);\n    BN_clear_free(r->priv_key);\n    OPENSSL_clear_free((void *)r, sizeof(EC_KEY));\n}', "int BN_dec2bn(BIGNUM **bn, const char *a)\n{\n    BIGNUM *ret = NULL;\n    BN_ULONG l = 0;\n    int neg = 0, i, j;\n    int num;\n    if (a == NULL || *a == '\\0')\n        return 0;\n    if (*a == '-') {\n        neg = 1;\n        a++;\n    }\n    for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++)\n        continue;\n    if (i == 0 || i > INT_MAX / 4)\n        goto err;\n    num = i + neg;\n    if (bn == NULL)\n        return num;\n    if (*bn == NULL) {\n        if ((ret = BN_new()) == NULL)\n            return 0;\n    } else {\n        ret = *bn;\n        BN_zero(ret);\n    }\n    if (bn_expand(ret, i * 4) == NULL)\n        goto err;\n    j = BN_DEC_NUM - i % BN_DEC_NUM;\n    if (j == BN_DEC_NUM)\n        j = 0;\n    l = 0;\n    while (--i >= 0) {\n        l *= 10;\n        l += *a - '0';\n        a++;\n        if (++j == BN_DEC_NUM) {\n            if (!BN_mul_word(ret, BN_DEC_CONV)\n                || !BN_add_word(ret, l))\n                goto err;\n            l = 0;\n            j = 0;\n        }\n    }\n    bn_correct_top(ret);\n    *bn = ret;\n    bn_check_top(ret);\n    if (ret->top != 0)\n        ret->neg = neg;\n    return num;\n err:\n    if (*bn == NULL)\n        BN_free(ret);\n    return 0;\n}", 'int BN_set_word(BIGNUM *a, BN_ULONG w)\n{\n    bn_check_top(a);\n    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)\n        return 0;\n    a->neg = 0;\n    a->d[0] = w;\n    a->top = (w ? 1 : 0);\n    a->flags &= ~BN_FLG_FIXED_TOP;\n    bn_check_top(a);\n    return 1;\n}', 'static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)\n{\n    if (bits > (INT_MAX - BN_BITS2 + 1))\n        return NULL;\n    if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)\n        return a;\n    return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);\n}']