crypto/bn/bn_kron.c:117: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] Size: [0, 8388607] by call to `BN_rshift`.
Showing all 11 steps of the trace


crypto/bn/bn_kron.c:81:9: Call
79.   
80.       BN_CTX_start(ctx);
81.       A = BN_CTX_get(ctx);
              ^
82.       B = BN_CTX_get(ctx);
83.       if (B == NULL)

crypto/bn/bn_ctx.c:275:5: Call
  273.       }
  274.       /* OK, make sure the returned bignum is "zero" */
  275.       BN_zero(ret);
             ^
  276.       ctx->used++;
  277.       CTXDBG_RET(ctx, ret);

crypto/bn/bn_lib.c:520:1: Parameter `*a->d`
    518.   }
    519.   
    520. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    521.   {
    522.       bn_check_top(a);

crypto/bn/bn_lib.c:523:9: Call
    521.   {
    522.       bn_check_top(a);
    523.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    524.           return (0);
    525.       a->neg = 0;

crypto/bn/bn_lcl.h:777:1: Parameter `*a->d`
      775.   int bn_probable_prime_dh_coprime(BIGNUM *rnd, int bits, BN_CTX *ctx);
      776.   
      777. > static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
      778.   {
      779.       if (bits > (INT_MAX - BN_BITS2 + 1))

crypto/bn/bn_kron.c:117:12: Call
115.       while (!BN_is_bit_set(B, i))
116.           i++;
117.       err = !BN_rshift(B, B, i);
                  ^
118.       if (err)
119.           goto end;

crypto/bn/bn_shift.c:168:1: <Length trace>
166.   }
167.   
168. > int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
169.   {
170.       int i, j, nw, lb, rb;

crypto/bn/bn_shift.c:168:1: Parameter `*a->d`
  166.   }
  167.   
  168. > int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
  169.   {
  170.       int i, j, nw, lb, rb;

crypto/bn/bn_shift.c:199:5: Assignment
  197.       }
  198.   
  199.       f = &(a->d[nw]);
             ^
  200.       t = r->d;
  201.       j = a->top - nw;

crypto/bn/bn_shift.c:208:15: Assignment
  206.               *(t++) = *(f++);
  207.       } else {
  208.           l = *(f++);
                       ^
  209.           for (i = j - 1; i != 0; i--) {
  210.               tmp = (l >> rb) & BN_MASK2;

crypto/bn/bn_shift.c:211:17: Array access: Offset: [1, +oo] Size: [0, 8388607] by call to `BN_rshift` 
  209.           for (i = j - 1; i != 0; i--) {
  210.               tmp = (l >> rb) & BN_MASK2;
  211.               l = *(f++);
                         ^
  212.               *(t++) = (tmp | (l << lb)) & BN_MASK2;
  213.           }

int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
{
    int i, j, nw, lb, rb;
    BN_ULONG *t, *f;
    BN_ULONG l, tmp;
    bn_check_top(r);
    bn_check_top(a);
    if (n < 0) {
        BNerr(BN_F_BN_RSHIFT, BN_R_INVALID_SHIFT);
        return 0;
    }
    nw = n / BN_BITS2;
    rb = n % BN_BITS2;
    lb = BN_BITS2 - rb;
    if (nw >= a->top || a->top == 0) {
        BN_zero(r);
        return (1);
    }
    i = (BN_num_bits(a) - n + (BN_BITS2 - 1)) / BN_BITS2;
    if (r != a) {
        r->neg = a->neg;
        if (bn_wexpand(r, i) == NULL)
            return (0);
    } else {
        if (n == 0)
            return 1;
    }
    f = &(a->d[nw]);
    t = r->d;
    j = a->top - nw;
    r->top = i;
    if (rb == 0) {
        for (i = j; i != 0; i--)
            *(t++) = *(f++);
    } else {
        l = *(f++);
        for (i = j - 1; i != 0; i--) {
            tmp = (l >> rb) & BN_MASK2;
            l = *(f++);
            *(t++) = (tmp | (l << lb)) & BN_MASK2;
        }
        if ((l = (l >> rb) & BN_MASK2))
            *(t) = l;
    }
    bn_check_top(r);
    return (1);
}
['int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    int i;\n    int ret = -2;\n    int err = 0;\n    BIGNUM *A, *B, *tmp;\n    static const int tab[8] = { 0, 1, 0, -1, 0, -1, 0, 1 };\n    bn_check_top(a);\n    bn_check_top(b);\n    BN_CTX_start(ctx);\n    A = BN_CTX_get(ctx);\n    B = BN_CTX_get(ctx);\n    if (B == NULL)\n        goto end;\n    err = !BN_copy(A, a);\n    if (err)\n        goto end;\n    err = !BN_copy(B, b);\n    if (err)\n        goto end;\n    if (BN_is_zero(B)) {\n        ret = BN_abs_is_word(A, 1);\n        goto end;\n    }\n    if (!BN_is_odd(A) && !BN_is_odd(B)) {\n        ret = 0;\n        goto end;\n    }\n    i = 0;\n    while (!BN_is_bit_set(B, i))\n        i++;\n    err = !BN_rshift(B, B, i);\n    if (err)\n        goto end;\n    if (i & 1) {\n        ret = tab[BN_lsw(A) & 7];\n    } else {\n        ret = 1;\n    }\n    if (B->neg) {\n        B->neg = 0;\n        if (A->neg)\n            ret = -ret;\n    }\n    while (1) {\n        if (BN_is_zero(A)) {\n            ret = BN_is_one(B) ? ret : 0;\n            goto end;\n        }\n        i = 0;\n        while (!BN_is_bit_set(A, i))\n            i++;\n        err = !BN_rshift(A, A, i);\n        if (err)\n            goto end;\n        if (i & 1) {\n            ret = ret * tab[BN_lsw(B) & 7];\n        }\n        if ((A->neg ? ~BN_lsw(A) : BN_lsw(A)) & BN_lsw(B) & 2)\n            ret = -ret;\n        err = !BN_nnmod(B, B, A, ctx);\n        if (err)\n            goto end;\n        tmp = A;\n        A = B;\n        B = tmp;\n        tmp->neg = 0;\n    }\n end:\n    BN_CTX_end(ctx);\n    if (err)\n        return -2;\n    else\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}', '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}', 'int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int i, j, nw, lb, rb;\n    BN_ULONG *t, *f;\n    BN_ULONG l, tmp;\n    bn_check_top(r);\n    bn_check_top(a);\n    if (n < 0) {\n        BNerr(BN_F_BN_RSHIFT, BN_R_INVALID_SHIFT);\n        return 0;\n    }\n    nw = n / BN_BITS2;\n    rb = n % BN_BITS2;\n    lb = BN_BITS2 - rb;\n    if (nw >= a->top || a->top == 0) {\n        BN_zero(r);\n        return (1);\n    }\n    i = (BN_num_bits(a) - n + (BN_BITS2 - 1)) / BN_BITS2;\n    if (r != a) {\n        r->neg = a->neg;\n        if (bn_wexpand(r, i) == NULL)\n            return (0);\n    } else {\n        if (n == 0)\n            return 1;\n    }\n    f = &(a->d[nw]);\n    t = r->d;\n    j = a->top - nw;\n    r->top = i;\n    if (rb == 0) {\n        for (i = j; i != 0; i--)\n            *(t++) = *(f++);\n    } else {\n        l = *(f++);\n        for (i = j - 1; i != 0; i--) {\n            tmp = (l >> rb) & BN_MASK2;\n            l = *(f++);\n            *(t++) = (tmp | (l << lb)) & BN_MASK2;\n        }\n        if ((l = (l >> rb) & BN_MASK2))\n            *(t) = l;\n    }\n    bn_check_top(r);\n    return (1);\n}']