test/bntest.c:1087: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] Size: [0, 8388607] by call to `BN_lshift`.
Showing all 11 steps of the trace


test/bntest.c:1081:5: Assignment
1079.   {
1080.       BIGNUM *a = NULL, *lshift = NULL, *ret = NULL;
1081.       int n = 0, st = 0;
            ^
1082.   
1083.       if (!TEST_ptr(a = getBN(s, "A"))

test/bntest.c:1087:10: Call
1085.               || !TEST_ptr(ret = BN_new()))
1086.   
1087.       if (!TEST_true(BN_lshift(ret, a, n))
                 ^
1088.               || !equalBN("A << N", lshift, ret)
1089.               || !TEST_true(BN_rshift(ret, lshift, n))

crypto/bn/bn_shift.c:83:1: <Offset trace>
81.   }
82.   
83. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
84.   {
85.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:83:1: Parameter `n`
  81.   }
  82.   
  83. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
  84.   {
  85.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:97:5: Assignment
  95.       }
  96.   
  97.       nw = n / BN_BITS2;
             ^
  98.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
  99.           return (0);

crypto/bn/bn_shift.c:83:1: <Length trace>
81.   }
82.   
83. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
84.   {
85.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:83:1: Parameter `*r->d`
  81.   }
  82.   
  83. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
  84.   {
  85.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:98:9: Call
  96.   
  97.       nw = n / BN_BITS2;
  98.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
                 ^
  99.           return (0);
  100.       r->neg = a->neg;

crypto/bn/bn_lib.c:948:1: Parameter `*a->d`
    946.   }
    947.   
    948. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
    949.   {
    950.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_shift.c:104:5: Assignment
  102.       rb = BN_BITS2 - lb;
  103.       f = a->d;
  104.       t = r->d;
             ^
  105.       t[a->top + nw] = 0;
  106.       if (lb == 0)

crypto/bn/bn_shift.c:112:13: Array access: Offset: [1, +oo] Size: [0, 8388607] by call to `BN_lshift` 
  110.           for (i = a->top - 1; i >= 0; i--) {
  111.               l = f[i];
  112.               t[nw + i + 1] |= (l >> rb) & BN_MASK2;
                     ^
  113.               t[nw + i] = (l << lb) & BN_MASK2;
  114.           }

int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
{
    int i, nw, lb, rb;
    BN_ULONG *t, *f;
    BN_ULONG l;
    bn_check_top(r);
    bn_check_top(a);
    if (n < 0) {
        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);
        return 0;
    }
    nw = n / BN_BITS2;
    if (bn_wexpand(r, a->top + nw + 1) == NULL)
        return (0);
    r->neg = a->neg;
    lb = n % BN_BITS2;
    rb = BN_BITS2 - lb;
    f = a->d;
    t = r->d;
    t[a->top + nw] = 0;
    if (lb == 0)
        for (i = a->top - 1; i >= 0; i--)
            t[nw + i] = f[i];
    else
        for (i = a->top - 1; i >= 0; i--) {
            l = f[i];
            t[nw + i + 1] |= (l >> rb) & BN_MASK2;
            t[nw + i] = (l << lb) & BN_MASK2;
        }
    memset(t, 0, sizeof(*t) * nw);
    r->top = a->top + nw + 1;
    bn_correct_top(r);
    bn_check_top(r);
    return (1);
}
['static int file_lshift(STANZA *s)\n{\n    BIGNUM *a = NULL, *lshift = NULL, *ret = NULL;\n    int n = 0, st = 0;\n    if (!TEST_ptr(a = getBN(s, "A"))\n            || !TEST_ptr(lshift = getBN(s, "LShift"))\n            || !TEST_ptr(ret = BN_new()))\n    if (!TEST_true(BN_lshift(ret, a, n))\n            || !equalBN("A << N", lshift, ret)\n            || !TEST_true(BN_rshift(ret, lshift, n))\n            || !equalBN("A >> N", a, ret))\n        goto err;\n    st = 1;\nerr:\n    BN_free(a);\n    BN_free(lshift);\n    BN_free(ret);\n    return st;\n}', 'int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int i, nw, lb, rb;\n    BN_ULONG *t, *f;\n    BN_ULONG l;\n    bn_check_top(r);\n    bn_check_top(a);\n    if (n < 0) {\n        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);\n        return 0;\n    }\n    nw = n / BN_BITS2;\n    if (bn_wexpand(r, a->top + nw + 1) == NULL)\n        return (0);\n    r->neg = a->neg;\n    lb = n % BN_BITS2;\n    rb = BN_BITS2 - lb;\n    f = a->d;\n    t = r->d;\n    t[a->top + nw] = 0;\n    if (lb == 0)\n        for (i = a->top - 1; i >= 0; i--)\n            t[nw + i] = f[i];\n    else\n        for (i = a->top - 1; i >= 0; i--) {\n            l = f[i];\n            t[nw + i + 1] |= (l >> rb) & BN_MASK2;\n            t[nw + i] = (l << lb) & BN_MASK2;\n        }\n    memset(t, 0, sizeof(*t) * nw);\n    r->top = a->top + nw + 1;\n    bn_correct_top(r);\n    bn_check_top(r);\n    return (1);\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}']