crypto/ec/ecdsa_ossl.c:449: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: [1, +oo] by call to `BN_mod_mul`.
Showing all 17 steps of the trace


crypto/ec/ecdsa_ossl.c:399:5: Call
397.           return -1;
398.       }
399.       BN_CTX_start(ctx);
           ^
400.       order = BN_CTX_get(ctx);
401.       u1 = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:236:1: Parameter `ctx->stack.depth`
  234.   }
  235.   
  236. > void BN_CTX_start(BN_CTX *ctx)
  237.   {
  238.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/ec/ecdsa_ossl.c:449:10: Call
447.       }
448.       /* u2 = r * w mod q */
449.       if (!BN_mod_mul(u2, sig->r, u2, order, ctx)) {
                ^
450.           ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);
451.           goto err;

crypto/bn/bn_mod.c:179:1: Parameter `ctx->stack.depth`
  177.   
  178.   /* slow but works */
  179. > int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
  180.                  BN_CTX *ctx)
  181.   {

crypto/bn/bn_mod.c:189:5: Call
  187.       bn_check_top(m);
  188.   
  189.       BN_CTX_start(ctx);
             ^
  190.       if ((t = BN_CTX_get(ctx)) == NULL)
  191.           goto err;

crypto/bn/bn_ctx.c:236:1: Parameter `ctx->stack.depth`
    234.   }
    235.   
    236. > void BN_CTX_start(BN_CTX *ctx)
    237.   {
    238.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_mod.c:196:14: Call
  194.               goto err;
  195.       } else {
  196.           if (!BN_mul(t, a, b, ctx))
                      ^
  197.               goto err;
  198.       }

crypto/bn/bn_mul.c:909:5: Call
    907.       top = al + bl;
    908.   
    909.       BN_CTX_start(ctx);
               ^
    910.       if ((r == a) || (r == b)) {
    911.           if ((rr = BN_CTX_get(ctx)) == NULL)

crypto/bn/bn_ctx.c:236:1: Parameter `*ctx->stack.indexes`
      234.   }
      235.   
      236. > void BN_CTX_start(BN_CTX *ctx)
      237.   {
      238.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_mul.c:1033:5: Call
    1031.    err:
    1032.       bn_check_top(r);
    1033.       BN_CTX_end(ctx);
                ^
    1034.       return (ret);
    1035.   }

crypto/bn/bn_ctx.c:250:1: Parameter `*ctx->stack.indexes`
      248.   }
      249.   
      250. > void BN_CTX_end(BN_CTX *ctx)
      251.   {
      252.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:256:27: Call
      254.           ctx->err_stack--;
      255.       else {
      256.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                       ^
      257.           /* Does this stack frame have anything to release? */
      258.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:326:1: <Offset trace>
324.   }
325.   
326. > static unsigned int BN_STACK_pop(BN_STACK *st)
327.   {
328.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:326:1: Parameter `st->depth`
        324.   }
        325.   
        326. > static unsigned int BN_STACK_pop(BN_STACK *st)
        327.   {
        328.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:326:1: <Length trace>
324.   }
325.   
326. > static unsigned int BN_STACK_pop(BN_STACK *st)
327.   {
328.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:326:1: Parameter `*st->indexes`
        324.   }
        325.   
        326. > static unsigned int BN_STACK_pop(BN_STACK *st)
        327.   {
        328.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:328:12: Array access: Offset: [-1, +oo] Size: [1, +oo] by call to `BN_mod_mul` 
        326.   static unsigned int BN_STACK_pop(BN_STACK *st)
        327.   {
        328.       return st->indexes[--(st->depth)];
                          ^
        329.   }
        330.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,\n                          const ECDSA_SIG *sig, EC_KEY *eckey)\n{\n    int ret = -1, i;\n    BN_CTX *ctx;\n    BIGNUM *order, *u1, *u2, *m, *X;\n    EC_POINT *point = NULL;\n    const EC_GROUP *group;\n    const EC_POINT *pub_key;\n    if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL ||\n        (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || sig == NULL) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, EC_R_MISSING_PARAMETERS);\n        return -1;\n    }\n    ctx = BN_CTX_new();\n    if (ctx == NULL) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_MALLOC_FAILURE);\n        return -1;\n    }\n    BN_CTX_start(ctx);\n    order = BN_CTX_get(ctx);\n    u1 = BN_CTX_get(ctx);\n    u2 = BN_CTX_get(ctx);\n    m = BN_CTX_get(ctx);\n    X = BN_CTX_get(ctx);\n    if (X == NULL) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);\n        goto err;\n    }\n    if (!EC_GROUP_get_order(group, order, ctx)) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);\n        goto err;\n    }\n    if (BN_is_zero(sig->r) || BN_is_negative(sig->r) ||\n        BN_ucmp(sig->r, order) >= 0 || BN_is_zero(sig->s) ||\n        BN_is_negative(sig->s) || BN_ucmp(sig->s, order) >= 0) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, EC_R_BAD_SIGNATURE);\n        ret = 0;\n        goto err;\n    }\n    if (!BN_mod_inverse(u2, sig->s, order, ctx)) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);\n        goto err;\n    }\n    i = BN_num_bits(order);\n    if (8 * dgst_len > i)\n        dgst_len = (i + 7) / 8;\n    if (!BN_bin2bn(dgst, dgst_len, m)) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);\n        goto err;\n    }\n    if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);\n        goto err;\n    }\n    if (!BN_mod_mul(u1, m, u2, order, ctx)) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);\n        goto err;\n    }\n    if (!BN_mod_mul(u2, sig->r, u2, order, ctx)) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);\n        goto err;\n    }\n    if ((point = EC_POINT_new(group)) == NULL) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!EC_POINT_mul(group, point, u1, pub_key, u2, ctx)) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);\n        goto err;\n    }\n    if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) ==\n        NID_X9_62_prime_field) {\n        if (!EC_POINT_get_affine_coordinates_GFp(group, point, X, NULL, ctx)) {\n            ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);\n            goto err;\n        }\n    }\n#ifndef OPENSSL_NO_EC2M\n    else {\n        if (!EC_POINT_get_affine_coordinates_GF2m(group, point, X, NULL, ctx)) {\n            ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);\n            goto err;\n        }\n    }\n#endif\n    if (!BN_nnmod(u1, X, order, ctx)) {\n        ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);\n        goto err;\n    }\n    ret = (BN_ucmp(u1, sig->r) == 0);\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(ctx);\n    EC_POINT_free(point);\n    return ret;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY("BN_CTX_start", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        ctx->err_stack++;\n    else if (!BN_STACK_push(&ctx->stack, ctx->used)) {\n        BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        ctx->err_stack++;\n    }\n    CTXDBG_EXIT(ctx);\n}', 'int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    BIGNUM *t;\n    int ret = 0;\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(m);\n    BN_CTX_start(ctx);\n    if ((t = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (a == b) {\n        if (!BN_sqr(t, a, ctx))\n            goto err;\n    } else {\n        if (!BN_mul(t, a, b, ctx))\n            goto err;\n    }\n    if (!BN_nnmod(r, t, m, ctx))\n        goto err;\n    bn_check_top(r);\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    return (ret);\n}', 'int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    int top, al, bl;\n    BIGNUM *rr;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    int i;\n#endif\n#ifdef BN_RECURSION\n    BIGNUM *t = NULL;\n    int j = 0, k;\n#endif\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(r);\n    al = a->top;\n    bl = b->top;\n    if ((al == 0) || (bl == 0)) {\n        BN_zero(r);\n        return (1);\n    }\n    top = al + bl;\n    BN_CTX_start(ctx);\n    if ((r == a) || (r == b)) {\n        if ((rr = BN_CTX_get(ctx)) == NULL)\n            goto err;\n    } else\n        rr = r;\n    rr->neg = a->neg ^ b->neg;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    i = al - bl;\n#endif\n#ifdef BN_MUL_COMBA\n    if (i == 0) {\n# if 0\n        if (al == 4) {\n            if (bn_wexpand(rr, 8) == NULL)\n                goto err;\n            rr->top = 8;\n            bn_mul_comba4(rr->d, a->d, b->d);\n            goto end;\n        }\n# endif\n        if (al == 8) {\n            if (bn_wexpand(rr, 16) == NULL)\n                goto err;\n            rr->top = 16;\n            bn_mul_comba8(rr->d, a->d, b->d);\n            goto end;\n        }\n    }\n#endif\n#ifdef BN_RECURSION\n    if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) {\n        if (i >= -1 && i <= 1) {\n            if (i >= 0) {\n                j = BN_num_bits_word((BN_ULONG)al);\n            }\n            if (i == -1) {\n                j = BN_num_bits_word((BN_ULONG)bl);\n            }\n            j = 1 << (j - 1);\n            assert(j <= al || j <= bl);\n            k = j + j;\n            t = BN_CTX_get(ctx);\n            if (t == NULL)\n                goto err;\n            if (al > j || bl > j) {\n                if (bn_wexpand(t, k * 4) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 4) == NULL)\n                    goto err;\n                bn_mul_part_recursive(rr->d, a->d, b->d,\n                                      j, al - j, bl - j, t->d);\n            } else {\n                if (bn_wexpand(t, k * 2) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 2) == NULL)\n                    goto err;\n                bn_mul_recursive(rr->d, a->d, b->d, j, al - j, bl - j, t->d);\n            }\n            rr->top = top;\n            goto end;\n        }\n# if 0\n        if (i == 1 && !BN_get_flags(b, BN_FLG_STATIC_DATA)) {\n            BIGNUM *tmp_bn = (BIGNUM *)b;\n            if (bn_wexpand(tmp_bn, al) == NULL)\n                goto err;\n            tmp_bn->d[bl] = 0;\n            bl++;\n            i--;\n        } else if (i == -1 && !BN_get_flags(a, BN_FLG_STATIC_DATA)) {\n            BIGNUM *tmp_bn = (BIGNUM *)a;\n            if (bn_wexpand(tmp_bn, bl) == NULL)\n                goto err;\n            tmp_bn->d[al] = 0;\n            al++;\n            i++;\n        }\n        if (i == 0) {\n            j = BN_num_bits_word((BN_ULONG)al);\n            j = 1 << (j - 1);\n            k = j + j;\n            t = BN_CTX_get(ctx);\n            if (al == j) {\n                if (bn_wexpand(t, k * 2) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 2) == NULL)\n                    goto err;\n                bn_mul_recursive(rr->d, a->d, b->d, al, t->d);\n            } else {\n                if (bn_wexpand(t, k * 4) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 4) == NULL)\n                    goto err;\n                bn_mul_part_recursive(rr->d, a->d, b->d, al - j, j, t->d);\n            }\n            rr->top = top;\n            goto end;\n        }\n# endif\n    }\n#endif\n    if (bn_wexpand(rr, top) == NULL)\n        goto err;\n    rr->top = top;\n    bn_mul_normal(rr->d, a->d, al, b->d, bl);\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n end:\n#endif\n    bn_correct_top(rr);\n    if (r != rr)\n        BN_copy(r, rr);\n    ret = 1;\n err:\n    bn_check_top(r);\n    BN_CTX_end(ctx);\n    return (ret);\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY("BN_CTX_end", ctx);\n    if (ctx->err_stack)\n        ctx->err_stack--;\n    else {\n        unsigned int fp = BN_STACK_pop(&ctx->stack);\n        if (fp < ctx->used)\n            BN_POOL_release(&ctx->pool, ctx->used - fp);\n        ctx->used = fp;\n        ctx->too_many = 0;\n    }\n    CTXDBG_EXIT(ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']