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


crypto/dh/dh_gen.c:69:10: Call
67.           goto err;
68.       BN_CTX_start(ctx);
69.       t1 = BN_CTX_get(ctx);
               ^
70.       t2 = BN_CTX_get(ctx);
71.       if (t2 == NULL)

crypto/bn/bn_ctx.c:229:5: Call
  227.       }
  228.       /* OK, make sure the returned bignum is "zero" */
  229.       BN_zero(ret);
             ^
  230.       ctx->used++;
  231.       CTXDBG_RET(ctx, ret);

crypto/bn/bn_lib.c:395:1: Parameter `*a->d`
    393.   }
    394.   
    395. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    396.   {
    397.       bn_check_top(a);

crypto/bn/bn_lib.c:398:9: Call
    396.   {
    397.       bn_check_top(a);
    398.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    399.           return (0);
    400.       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/dh/dh_gen.c:91:14: Call
89.           g = 2;
90.       } else if (generator == DH_GENERATOR_5) {
91.           if (!BN_set_word(t1, 10))
                   ^
92.               goto err;
93.           if (!BN_set_word(t2, 3))

crypto/bn/bn_lib.c:395:1: <Length trace>
393.   }
394.   
395. > int BN_set_word(BIGNUM *a, BN_ULONG w)
396.   {
397.       bn_check_top(a);

crypto/bn/bn_lib.c:395:1: Parameter `*a->d`
  393.   }
  394.   
  395. > int BN_set_word(BIGNUM *a, BN_ULONG w)
  396.   {
  397.       bn_check_top(a);

crypto/bn/bn_lib.c:398:9: Call
  396.   {
  397.       bn_check_top(a);
  398.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                 ^
  399.           return (0);
  400.       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:401:5: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_set_word` 
  399.           return (0);
  400.       a->neg = 0;
  401.       a->d[0] = w;
             ^
  402.       a->top = (w ? 1 : 0);
  403.       bn_check_top(a);

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);
    bn_check_top(a);
    return (1);
}
['static int dh_builtin_genparams(DH *ret, int prime_len, int generator,\n                                BN_GENCB *cb)\n{\n    BIGNUM *t1, *t2;\n    int g, ok = -1;\n    BN_CTX *ctx = NULL;\n    ctx = BN_CTX_new();\n    if (ctx == NULL)\n        goto err;\n    BN_CTX_start(ctx);\n    t1 = BN_CTX_get(ctx);\n    t2 = BN_CTX_get(ctx);\n    if (t2 == NULL)\n        goto err;\n    if (!ret->p && ((ret->p = BN_new()) == NULL))\n        goto err;\n    if (!ret->g && ((ret->g = BN_new()) == NULL))\n        goto err;\n    if (generator <= 1) {\n        DHerr(DH_F_DH_BUILTIN_GENPARAMS, DH_R_BAD_GENERATOR);\n        goto err;\n    }\n    if (generator == DH_GENERATOR_2) {\n        if (!BN_set_word(t1, 24))\n            goto err;\n        if (!BN_set_word(t2, 11))\n            goto err;\n        g = 2;\n    } else if (generator == DH_GENERATOR_5) {\n        if (!BN_set_word(t1, 10))\n            goto err;\n        if (!BN_set_word(t2, 3))\n            goto err;\n        g = 5;\n    } else {\n        if (!BN_set_word(t1, 2))\n            goto err;\n        if (!BN_set_word(t2, 1))\n            goto err;\n        g = generator;\n    }\n    if (!BN_generate_prime_ex(ret->p, prime_len, 1, t1, t2, cb))\n        goto err;\n    if (!BN_GENCB_call(cb, 3, 0))\n        goto err;\n    if (!BN_set_word(ret->g, g))\n        goto err;\n    ok = 1;\n err:\n    if (ok == -1) {\n        DHerr(DH_F_DH_BUILTIN_GENPARAMS, ERR_R_BN_LIB);\n        ok = 0;\n    }\n    if (ctx != NULL) {\n        BN_CTX_end(ctx);\n        BN_CTX_free(ctx);\n    }\n    return ok;\n}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n{\n    BIGNUM *ret;\n    CTXDBG_ENTRY("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    ctx->used++;\n    CTXDBG_RET(ctx, ret);\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    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}']