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


crypto/dh/dh_gen.c:107:1: Parameter `ret->g->d`
105.    * order-q subgroup.
106.    */
107. > static int dh_builtin_genparams(DH *ret, int prime_len, int generator,
108.                                   BN_GENCB *cb)
109.   {

crypto/dh/dh_gen.c:165:10: Call
163.       if (!BN_GENCB_call(cb, 3, 0))
164.           goto err;
165.       if (!BN_set_word(ret->g, g))
                ^
166.           goto err;
167.       ok = 1;

crypto/bn/bn_lib.c:530:1: <Length trace>
528.   }
529.   
530. > int BN_set_word(BIGNUM *a, BN_ULONG w)
531.   {
532.       bn_check_top(a);

crypto/bn/bn_lib.c:530:1: Parameter `*a->d`
  528.   }
  529.   
  530. > int BN_set_word(BIGNUM *a, BN_ULONG w)
  531.   {
  532.       bn_check_top(a);

crypto/bn/bn_lib.c:536:5: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_set_word` 
  534.           return (0);
  535.       a->neg = 0;
  536.       a->d[0] = w;
             ^
  537.       a->top = (w ? 1 : 0);
  538.       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 (t1 == NULL || 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}', '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}']