test/test_test.c:294: error: BUFFER_OVERRUN_L2
  Offset: [0, 536870912] (⇐ [0, 1] + [0, 536870911]) Size: 2 by call to `BN_dec2bn`.
Showing all 6 steps of the trace


test/test_test.c:294:10: Call
292.       int r = 0;
293.   
294.       if (!TEST(1, TEST_int_eq(BN_dec2bn(&a, "0"), 1))
                ^
295.           | !TEST(1, TEST_BN_eq_word(a, 0))
296.           | !TEST(0, TEST_BN_eq_word(a, 30))

crypto/bn/bn_print.c:213:10: <Offset trace>
211.       }
212.   
213.       for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++)
                ^
214.           continue;
215.   

crypto/bn/bn_print.c:213:10: Assignment
  211.       }
  212.   
  213.       for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++)
                  ^
  214.           continue;
  215.   

crypto/bn/bn_print.c:199:1: <Length trace>
197.   }
198.   
199. > int BN_dec2bn(BIGNUM **bn, const char *a)
200.   {
201.       BIGNUM *ret = NULL;

crypto/bn/bn_print.c:199:1: Parameter `*a`
  197.   }
  198.   
  199. > int BN_dec2bn(BIGNUM **bn, const char *a)
  200.   {
  201.       BIGNUM *ret = NULL;

crypto/bn/bn_print.c:213:37: Array access: Offset: [0, 536870912] (⇐ [0, 1] + [0, 536870911]) Size: 2 by call to `BN_dec2bn` 
  211.       }
  212.   
  213.       for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++)
                                             ^
  214.           continue;
  215.   

int BN_dec2bn(BIGNUM **bn, const char *a)
{
    BIGNUM *ret = NULL;
    BN_ULONG l = 0;
    int neg = 0, i, j;
    int num;
    if (a == NULL || *a == '\0')
        return 0;
    if (*a == '-') {
        neg = 1;
        a++;
    }
    for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++)
        continue;
    if (i == 0 || i > INT_MAX / 4)
        goto err;
    num = i + neg;
    if (bn == NULL)
        return num;
    if (*bn == NULL) {
        if ((ret = BN_new()) == NULL)
            return 0;
    } else {
        ret = *bn;
        BN_zero(ret);
    }
    if (bn_expand(ret, i * 4) == NULL)
        goto err;
    j = BN_DEC_NUM - i % BN_DEC_NUM;
    if (j == BN_DEC_NUM)
        j = 0;
    l = 0;
    while (--i >= 0) {
        l *= 10;
        l += *a - '0';
        a++;
        if (++j == BN_DEC_NUM) {
            if (!BN_mul_word(ret, BN_DEC_CONV)
                || !BN_add_word(ret, l))
                goto err;
            l = 0;
            j = 0;
        }
    }
    bn_correct_top(ret);
    *bn = ret;
    bn_check_top(ret);
    if (ret->top != 0)
        ret->neg = neg;
    return num;
 err:
    if (*bn == NULL)
        BN_free(ret);
    return 0;
}
['static int test_bignum(void)\n{\n    BIGNUM *a = NULL, *b = NULL, *c = NULL;\n    int r = 0;\n    if (!TEST(1, TEST_int_eq(BN_dec2bn(&a, "0"), 1))\n        | !TEST(1, TEST_BN_eq_word(a, 0))\n        | !TEST(0, TEST_BN_eq_word(a, 30))\n        | !TEST(1, TEST_BN_abs_eq_word(a, 0))\n        | !TEST(0, TEST_BN_eq_one(a))\n        | !TEST(1, TEST_BN_eq_zero(a))\n        | !TEST(0, TEST_BN_ne_zero(a))\n        | !TEST(1, TEST_BN_le_zero(a))\n        | !TEST(0, TEST_BN_lt_zero(a))\n        | !TEST(1, TEST_BN_ge_zero(a))\n        | !TEST(0, TEST_BN_gt_zero(a))\n        | !TEST(1, TEST_BN_even(a))\n        | !TEST(0, TEST_BN_odd(a))\n        | !TEST(1, TEST_BN_eq(b, c))\n        | !TEST(0, TEST_BN_eq(a, b))\n        | !TEST(0, TEST_BN_ne(NULL, c))\n        | !TEST(1, TEST_int_eq(BN_dec2bn(&b, "1"), 1))\n        | !TEST(1, TEST_BN_eq_word(b, 1))\n        | !TEST(1, TEST_BN_eq_one(b))\n        | !TEST(0, TEST_BN_abs_eq_word(b, 0))\n        | !TEST(1, TEST_BN_abs_eq_word(b, 1))\n        | !TEST(0, TEST_BN_eq_zero(b))\n        | !TEST(1, TEST_BN_ne_zero(b))\n        | !TEST(0, TEST_BN_le_zero(b))\n        | !TEST(0, TEST_BN_lt_zero(b))\n        | !TEST(1, TEST_BN_ge_zero(b))\n        | !TEST(1, TEST_BN_gt_zero(b))\n        | !TEST(0, TEST_BN_even(b))\n        | !TEST(1, TEST_BN_odd(b))\n        | !TEST(1, TEST_int_eq(BN_dec2bn(&c, "-334739439"), 10))\n        | !TEST(0, TEST_BN_eq_word(c, 334739439))\n        | !TEST(1, TEST_BN_abs_eq_word(c, 334739439))\n        | !TEST(0, TEST_BN_eq_zero(c))\n        | !TEST(1, TEST_BN_ne_zero(c))\n        | !TEST(1, TEST_BN_le_zero(c))\n        | !TEST(1, TEST_BN_lt_zero(c))\n        | !TEST(0, TEST_BN_ge_zero(c))\n        | !TEST(0, TEST_BN_gt_zero(c))\n        | !TEST(0, TEST_BN_even(c))\n        | !TEST(1, TEST_BN_odd(c))\n        | !TEST(1, TEST_BN_eq(a, a))\n        | !TEST(0, TEST_BN_ne(a, a))\n        | !TEST(0, TEST_BN_eq(a, b))\n        | !TEST(1, TEST_BN_ne(a, b))\n        | !TEST(0, TEST_BN_lt(a, c))\n        | !TEST(1, TEST_BN_lt(c, b))\n        | !TEST(0, TEST_BN_lt(b, c))\n        | !TEST(0, TEST_BN_le(a, c))\n        | !TEST(1, TEST_BN_le(c, b))\n        | !TEST(0, TEST_BN_le(b, c))\n        | !TEST(1, TEST_BN_gt(a, c))\n        | !TEST(0, TEST_BN_gt(c, b))\n        | !TEST(1, TEST_BN_gt(b, c))\n        | !TEST(1, TEST_BN_ge(a, c))\n        | !TEST(0, TEST_BN_ge(c, b))\n        | !TEST(1, TEST_BN_ge(b, c)))\n        goto err;\n    r = 1;\nerr:\n    BN_free(a);\n    BN_free(b);\n    BN_free(c);\n    return r;\n}', "int BN_dec2bn(BIGNUM **bn, const char *a)\n{\n    BIGNUM *ret = NULL;\n    BN_ULONG l = 0;\n    int neg = 0, i, j;\n    int num;\n    if (a == NULL || *a == '\\0')\n        return 0;\n    if (*a == '-') {\n        neg = 1;\n        a++;\n    }\n    for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++)\n        continue;\n    if (i == 0 || i > INT_MAX / 4)\n        goto err;\n    num = i + neg;\n    if (bn == NULL)\n        return num;\n    if (*bn == NULL) {\n        if ((ret = BN_new()) == NULL)\n            return 0;\n    } else {\n        ret = *bn;\n        BN_zero(ret);\n    }\n    if (bn_expand(ret, i * 4) == NULL)\n        goto err;\n    j = BN_DEC_NUM - i % BN_DEC_NUM;\n    if (j == BN_DEC_NUM)\n        j = 0;\n    l = 0;\n    while (--i >= 0) {\n        l *= 10;\n        l += *a - '0';\n        a++;\n        if (++j == BN_DEC_NUM) {\n            if (!BN_mul_word(ret, BN_DEC_CONV)\n                || !BN_add_word(ret, l))\n                goto err;\n            l = 0;\n            j = 0;\n        }\n    }\n    bn_correct_top(ret);\n    *bn = ret;\n    bn_check_top(ret);\n    if (ret->top != 0)\n        ret->neg = neg;\n    return num;\n err:\n    if (*bn == NULL)\n        BN_free(ret);\n    return 0;\n}"]