crypto/bn/bn_prime.c:448: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_add_word`.
Showing all 9 steps of the trace


crypto/bn/bn_prime.c:443:25: Call
441.   
442.       BN_CTX_start(ctx);
443.       if ((offset_index = BN_CTX_get(ctx)) == NULL)
                               ^
444.           goto err;
445.       if ((offset_count = BN_CTX_get(ctx)) == NULL)

crypto/bn/bn_ctx.c:284:5: Call
  282.       }
  283.       /* OK, make sure the returned bignum is "zero" */
  284.       BN_zero(ret);
             ^
  285.       ctx->used++;
  286.       CTXDBG_RET(ctx, ret);

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_prime.c:448:5: Call
446.           goto err;
447.   
448.       BN_add_word(offset_count, prime_offset_count);
           ^
449.   
450.    loop:

crypto/bn/bn_word.c:123:1: Parameter `*a->d`
  121.   }
  122.   
  123. > int BN_add_word(BIGNUM *a, BN_ULONG w)
  124.   {
  125.       BN_ULONG l;

crypto/bn/bn_word.c:140:13: Call
  138.       if (a->neg) {
  139.           a->neg = 0;
  140.           i = BN_sub_word(a, w);
                     ^
  141.           if (!BN_is_zero(a))
  142.               a->neg = !(a->neg);

crypto/bn/bn_word.c:159:1: <Length trace>
157.   }
158.   
159. > int BN_sub_word(BIGNUM *a, BN_ULONG w)
160.   {
161.       int i;

crypto/bn/bn_word.c:159:1: Parameter `*a->d`
    157.   }
    158.   
    159. > int BN_sub_word(BIGNUM *a, BN_ULONG w)
    160.   {
    161.       int i;

crypto/bn/bn_word.c:184:27: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_add_word` 
    182.       }
    183.   
    184.       if ((a->top == 1) && (a->d[0] < w)) {
                                     ^
    185.           a->d[0] = w - a->d[0];
    186.           a->neg = 1;

int BN_sub_word(BIGNUM *a, BN_ULONG w)
{
    int i;
    bn_check_top(a);
    w &= BN_MASK2;
    if (!w)
        return 1;
    if (BN_is_zero(a)) {
        i = BN_set_word(a, w);
        if (i != 0)
            BN_set_negative(a, 1);
        return i;
    }
    if (a->neg) {
        a->neg = 0;
        i = BN_add_word(a, w);
        a->neg = 1;
        return (i);
    }
    if ((a->top == 1) && (a->d[0] < w)) {
        a->d[0] = w - a->d[0];
        a->neg = 1;
        return (1);
    }
    i = 0;
    for (;;) {
        if (a->d[i] >= w) {
            a->d[i] -= w;
            break;
        } else {
            a->d[i] = (a->d[i] - w) & BN_MASK2;
            i++;
            w = 1;
        }
    }
    if ((a->d[i] == 0) && (i == (a->top - 1)))
        a->top--;
    bn_check_top(a);
    return (1);
}
['int bn_probable_prime_dh_coprime(BIGNUM *rnd, int bits, BN_CTX *ctx)\n{\n    int i;\n    BIGNUM *offset_index;\n    BIGNUM *offset_count;\n    int ret = 0;\n    OPENSSL_assert(bits > prime_multiplier_bits);\n    BN_CTX_start(ctx);\n    if ((offset_index = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if ((offset_count = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    BN_add_word(offset_count, prime_offset_count);\n loop:\n    if (!BN_rand(rnd, bits - prime_multiplier_bits, 0, 1))\n        goto err;\n    if (BN_is_bit_set(rnd, bits))\n        goto loop;\n    if (!BN_rand_range(offset_index, offset_count))\n        goto err;\n    BN_mul_word(rnd, prime_multiplier);\n    BN_add_word(rnd, prime_offsets[BN_get_word(offset_index)]);\n    for (i = first_prime_index; i < NUMPRIMES; i++) {\n        if (BN_mod_word(rnd, (BN_ULONG)primes[i]) <= 1) {\n            goto loop;\n        }\n    }\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(rnd);\n    return ret;\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}', 'int BN_add_word(BIGNUM *a, BN_ULONG w)\n{\n    BN_ULONG l;\n    int i;\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (!w)\n        return 1;\n    if (BN_is_zero(a))\n        return BN_set_word(a, w);\n    if (a->neg) {\n        a->neg = 0;\n        i = BN_sub_word(a, w);\n        if (!BN_is_zero(a))\n            a->neg = !(a->neg);\n        return (i);\n    }\n    for (i = 0; w != 0 && i < a->top; i++) {\n        a->d[i] = l = (a->d[i] + w) & BN_MASK2;\n        w = (w > l) ? 1 : 0;\n    }\n    if (w && i == a->top) {\n        if (bn_wexpand(a, a->top + 1) == NULL)\n            return 0;\n        a->top++;\n        a->d[i] = w;\n    }\n    bn_check_top(a);\n    return (1);\n}', 'int BN_sub_word(BIGNUM *a, BN_ULONG w)\n{\n    int i;\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (!w)\n        return 1;\n    if (BN_is_zero(a)) {\n        i = BN_set_word(a, w);\n        if (i != 0)\n            BN_set_negative(a, 1);\n        return i;\n    }\n    if (a->neg) {\n        a->neg = 0;\n        i = BN_add_word(a, w);\n        a->neg = 1;\n        return (i);\n    }\n    if ((a->top == 1) && (a->d[0] < w)) {\n        a->d[0] = w - a->d[0];\n        a->neg = 1;\n        return (1);\n    }\n    i = 0;\n    for (;;) {\n        if (a->d[i] >= w) {\n            a->d[i] -= w;\n            break;\n        } else {\n            a->d[i] = (a->d[i] - w) & BN_MASK2;\n            i++;\n            w = 1;\n        }\n    }\n    if ((a->d[i] == 0) && (i == (a->top - 1)))\n        a->top--;\n    bn_check_top(a);\n    return (1);\n}']