test/bntest.c:197: error: BUFFER_OVERRUN_L3
  Offset: [0, 49] Size: [0, 8388607] by call to `BN_set_bit`.
Showing all 7 steps of the trace


test/bntest.c:68:1: Assignment
66.   } MPITEST;
67.   
68. > static const int NUM0 = 100;           /* number of tests */
69.   static const int NUM1 = 50;            /* additional tests for some functions */
70.   static FILE *fp;

test/bntest.c:197:18: Call
195.               BN_bntest_rand(a, 512, 0, 0);
196.               BN_copy(b, a);
197.               if (!TEST_int_ne(BN_set_bit(a, i), 0))
                        ^
198.                   goto err;
199.               BN_add_word(b, i);

crypto/bn/bn_lib.c:624:1: <Offset trace>
622.   }
623.   
624. > int BN_set_bit(BIGNUM *a, int n)
625.   {
626.       int i, j, k;

crypto/bn/bn_lib.c:624:1: Parameter `a->top`
  622.   }
  623.   
  624. > int BN_set_bit(BIGNUM *a, int n)
  625.   {
  626.       int i, j, k;

crypto/bn/bn_lib.c:624:1: <Length trace>
622.   }
623.   
624. > int BN_set_bit(BIGNUM *a, int n)
625.   {
626.       int i, j, k;

crypto/bn/bn_lib.c:624:1: Parameter `*a->d`
  622.   }
  623.   
  624. > int BN_set_bit(BIGNUM *a, int n)
  625.   {
  626.       int i, j, k;

crypto/bn/bn_lib.c:641:5: Array access: Offset: [0, 49] Size: [0, 8388607] by call to `BN_set_bit` 
  639.       }
  640.   
  641.       a->d[i] |= (((BN_ULONG)1) << j);
             ^
  642.       bn_check_top(a);
  643.       return (1);

int BN_set_bit(BIGNUM *a, int n)
{
    int i, j, k;
    if (n < 0)
        return 0;
    i = n / BN_BITS2;
    j = n % BN_BITS2;
    if (a->top <= i) {
        if (bn_wexpand(a, i + 1) == NULL)
            return (0);
        for (k = a->top; k < i + 1; k++)
            a->d[k] = 0;
        a->top = i + 1;
    }
    a->d[i] |= (((BN_ULONG)1) << j);
    bn_check_top(a);
    return (1);
}
['static int test_sub()\n{\n    BIGNUM *a = NULL, *b = NULL, *c = NULL;\n    int i, st = 0;\n    if (!TEST_ptr(a = BN_new())\n            || !TEST_ptr(b = BN_new())\n            || !TEST_ptr(c = BN_new()))\n        goto err;\n    for (i = 0; i < NUM0 + NUM1; i++) {\n        if (i < NUM1) {\n            BN_bntest_rand(a, 512, 0, 0);\n            BN_copy(b, a);\n            if (!TEST_int_ne(BN_set_bit(a, i), 0))\n                goto err;\n            BN_add_word(b, i);\n        } else {\n            BN_bntest_rand(b, 400 + i - NUM1, 0, 0);\n            a->neg = rand_neg();\n            b->neg = rand_neg();\n        }\n        BN_sub(c, a, b);\n        BN_add(c, c, b);\n        BN_sub(c, c, a);\n        if (!TEST_true(BN_is_zero(c)))\n            goto err;\n    }\n    st = 1;\nerr:\n    BN_free(a);\n    BN_free(b);\n    BN_free(c);\n    return st;\n}', 'int BN_set_bit(BIGNUM *a, int n)\n{\n    int i, j, k;\n    if (n < 0)\n        return 0;\n    i = n / BN_BITS2;\n    j = n % BN_BITS2;\n    if (a->top <= i) {\n        if (bn_wexpand(a, i + 1) == NULL)\n            return (0);\n        for (k = a->top; k < i + 1; k++)\n            a->d[k] = 0;\n        a->top = i + 1;\n    }\n    a->d[i] |= (((BN_ULONG)1) << j);\n    bn_check_top(a);\n    return (1);\n}']