crypto/rsa/rsa_sp800_56b_gen.c:353: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_set_word`.
Showing all 11 steps of the trace


crypto/rsa/rsa_sp800_56b_gen.c:348:11: Call
346.   
347.       BN_CTX_start(ctx);
348.       tmp = BN_CTX_get(ctx);
                 ^
349.       k = BN_CTX_get(ctx);
350.       if (k == NULL)

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

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

crypto/bn/bn_lib.c:362:9: Call
    360.   {
    361.       bn_check_top(a);
    362.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    363.           return 0;
    364.       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/rsa/rsa_sp800_56b_gen.c:353:12: Call
351.           goto err;
352.   
353.       ret = (BN_set_word(k, 2)
                  ^
354.             && BN_mod_exp(tmp, k, rsa->e, rsa->n, ctx)
355.             && BN_mod_exp(tmp, tmp, rsa->d, rsa->n, ctx)

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

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

crypto/bn/bn_lib.c:362:9: Call
  360.   {
  361.       bn_check_top(a);
  362.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                 ^
  363.           return 0;
  364.       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:365:5: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_set_word` 
  363.           return 0;
  364.       a->neg = 0;
  365.       a->d[0] = w;
             ^
  366.       a->top = (w ? 1 : 0);
  367.       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;
}
['int rsa_sp800_56b_pairwise_test(RSA *rsa, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *k, *tmp;\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    k = BN_CTX_get(ctx);\n    if (k == NULL)\n        goto err;\n    ret = (BN_set_word(k, 2)\n          && BN_mod_exp(tmp, k, rsa->e, rsa->n, ctx)\n          && BN_mod_exp(tmp, tmp, rsa->d, rsa->n, ctx)\n          && BN_cmp(k, tmp) == 0);\n    if (ret == 0)\n        RSAerr(RSA_F_RSA_SP800_56B_PAIRWISE_TEST, RSA_R_PAIRWISE_TEST_FAILURE);\nerr:\n    BN_CTX_end(ctx);\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}']