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


test/bntest.c:1132:5: Assignment
1130.       BIGNUM *lshift = getBN(s, "LShift");
1131.       BIGNUM *ret = BN_new();
1132.       int n = 0;
            ^
1133.       int st = 0;
1134.   

test/bntest.c:1135:56: Call
1133.       int st = 0;
1134.   
1135.       if (a == NULL || lshift == NULL || ret == NULL || !getint(s, &n, "N"))
                                                               ^
1136.           goto err;
1137.   

test/bntest.c:122:1: Parameter `*out`
  120.   }
  121.   
  122. > static int getint(STANZA *s, int *out, const char *attribute)
  123.   {
  124.       BIGNUM *ret = getBN(s, attribute);

test/bntest.c:1138:10: Call
1136.           goto err;
1137.   
1138.       if (!BN_lshift(ret, a, n)
                 ^
1139.               || !equalBN("A << N", lshift, ret)
1140.               || !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:1016:1: Parameter `*a->d`
    1014.   }
    1015.   
    1016. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1017.   {
    1018.       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 = getBN(s, "A");\n    BIGNUM *lshift = getBN(s, "LShift");\n    BIGNUM *ret = BN_new();\n    int n = 0;\n    int st = 0;\n    if (a == NULL || lshift == NULL || ret == NULL || !getint(s, &n, "N"))\n        goto err;\n    if (!BN_lshift(ret, a, n)\n            || !equalBN("A << N", lshift, ret)\n            || !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}', 'static int getint(STANZA *s, int *out, const char *attribute)\n{\n    BIGNUM *ret = getBN(s, attribute);\n    BN_ULONG word;\n    int st = 0;\n    if (ret == NULL)\n        goto err;\n    if ((word = BN_get_word(ret)) > INT_MAX)\n        goto err;\n    *out = (int)word;\n    st = 1;\nerr:\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}']