providers/fips/fipsprov.c:76: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_set_word`.
Showing all 11 steps of the trace


providers/fips/fipsprov.c:72:9: Call
70.           goto err;
71.       BN_CTX_start(bnctx);
72.       a = BN_CTX_get(bnctx);
              ^
73.       b = BN_CTX_get(bnctx);
74.       if (b == NULL)

crypto/bn/bn_ctx.c:238:5: Call
  236.       }
  237.       /* OK, make sure the returned bignum is "zero" */
  238.       BN_zero(ret);
             ^
  239.       /* clear BN_FLG_CONSTTIME if leaked from previous frames */
  240.       ret->flags &= (~BN_FLG_CONSTTIME);

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

crypto/bn/bn_lib.c:364:9: Call
    362.   {
    363.       bn_check_top(a);
    364.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    365.           return 0;
    366.       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))

providers/fips/fipsprov.c:76:5: Call
74.       if (b == NULL)
75.           goto err;
76.       BN_zero(a);
          ^
77.       if (!BN_one(b)
78.           || !BN_add(a, a, b)

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

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

crypto/bn/bn_lib.c:364:9: Call
  362.   {
  363.       bn_check_top(a);
  364.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                 ^
  365.           return 0;
  366.       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:367:5: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_set_word` 
  365.           return 0;
  366.       a->neg = 0;
  367.       a->d[0] = w;
             ^
  368.       a->top = (w ? 1 : 0);
  369.       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 dummy_evp_call(OPENSSL_CTX *libctx)\n{\n    EVP_MD_CTX *ctx = EVP_MD_CTX_new();\n    EVP_MD *sha256 = EVP_MD_fetch(libctx, "SHA256", NULL);\n    char msg[] = "Hello World!";\n    const unsigned char exptd[] = {\n        0x7f, 0x83, 0xb1, 0x65, 0x7f, 0xf1, 0xfc, 0x53, 0xb9, 0x2d, 0xc1, 0x81,\n        0x48, 0xa1, 0xd6, 0x5d, 0xfc, 0x2d, 0x4b, 0x1f, 0xa3, 0xd6, 0x77, 0x28,\n        0x4a, 0xdd, 0xd2, 0x00, 0x12, 0x6d, 0x90, 0x69\n    };\n    unsigned int dgstlen = 0;\n    unsigned char dgst[SHA256_DIGEST_LENGTH];\n    int ret = 0;\n    BN_CTX *bnctx = NULL;\n    BIGNUM *a = NULL, *b = NULL;\n    if (ctx == NULL || sha256 == NULL)\n        goto err;\n    if (!EVP_DigestInit_ex(ctx, sha256, NULL))\n        goto err;\n    if (!EVP_DigestUpdate(ctx, msg, sizeof(msg) - 1))\n        goto err;\n    if (!EVP_DigestFinal(ctx, dgst, &dgstlen))\n        goto err;\n    if (dgstlen != sizeof(exptd) || memcmp(dgst, exptd, sizeof(exptd)) != 0)\n        goto err;\n    bnctx = BN_CTX_new_ex(libctx);\n    if (bnctx == NULL)\n        goto err;\n    BN_CTX_start(bnctx);\n    a = BN_CTX_get(bnctx);\n    b = BN_CTX_get(bnctx);\n    if (b == NULL)\n        goto err;\n    BN_zero(a);\n    if (!BN_one(b)\n        || !BN_add(a, a, b)\n        || BN_cmp(a, b) != 0)\n        goto err;\n    ret = 1;\n err:\n    BN_CTX_end(bnctx);\n    BN_CTX_free(bnctx);\n    EVP_MD_CTX_free(ctx);\n    EVP_MD_meth_free(sha256);\n    return ret;\n}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n{\n    BIGNUM *ret;\n    CTXDBG("ENTER BN_CTX_get()", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        return NULL;\n    if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {\n        ctx->too_many = 1;\n        BNerr(BN_F_BN_CTX_GET, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        return NULL;\n    }\n    BN_zero(ret);\n    ret->flags &= (~BN_FLG_CONSTTIME);\n    ctx->used++;\n    CTXDBG("LEAVE BN_CTX_get()", ctx);\n    return ret;\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}']