test/bntest.c:1524: error: BUFFER_OVERRUN_L2
  Offset: [0, 536870912] (⇐ [0, 1] + [0, 536870911]) Size: 2 by call to `parsedecBN`.
Showing all 8 steps of the trace


test/bntest.c:1524:10: Call
1522.       int st = 0;
1523.   
1524.       if (!TEST_int_eq(parsedecBN(&bn, "0"), 1)
                 ^
1525.               || !TEST_BN_eq_word(bn, 0)
1526.               || !TEST_BN_eq_zero(bn)

test/bntest.c:103:1: Parameter `*in`
  101.   }
  102.   
  103. > static int parsedecBN(BIGNUM **out, const char *in)
  104.   {
  105.       *out = NULL;

test/bntest.c:106:12: Call
  104.   {
  105.       *out = NULL;
  106.       return BN_dec2bn(out, in);
                    ^
  107.   }
  108.   

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

crypto/bn/bn_print.c:211:10: Assignment
    209.       }
    210.   
    211.       for (i = 0; i <= (INT_MAX/4) && isdigit((unsigned char)a[i]); i++)
                    ^
    212.           continue;
    213.   

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

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

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

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) && isdigit((unsigned char)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_dec2bn()\n{\n    BIGNUM *bn = NULL;\n    int st = 0;\n    if (!TEST_int_eq(parsedecBN(&bn, "0"), 1)\n            || !TEST_BN_eq_word(bn, 0)\n            || !TEST_BN_eq_zero(bn)\n            || !TEST_BN_le_zero(bn)\n            || !TEST_BN_ge_zero(bn)\n            || !TEST_BN_even(bn))\n        goto err;\n    BN_free(bn);\n    bn = NULL;\n    if (!TEST_int_eq(parsedecBN(&bn, "256"), 3)\n            || !TEST_BN_eq_word(bn, 256)\n            || !TEST_BN_ge_zero(bn)\n            || !TEST_BN_gt_zero(bn)\n            || !TEST_BN_ne_zero(bn)\n            || !TEST_BN_even(bn))\n        goto err;\n    BN_free(bn);\n    bn = NULL;\n    if (!TEST_int_eq(parsedecBN(&bn, "-42"), 3)\n            || !TEST_BN_abs_eq_word(bn, 42)\n            || !TEST_BN_lt_zero(bn)\n            || !TEST_BN_le_zero(bn)\n            || !TEST_BN_ne_zero(bn)\n            || !TEST_BN_even(bn))\n        goto err;\n    BN_free(bn);\n    bn = NULL;\n    if (!TEST_int_eq(parsedecBN(&bn, "1"), 1)\n            || !TEST_BN_eq_word(bn, 1)\n            || !TEST_BN_ne_zero(bn)\n            || !TEST_BN_gt_zero(bn)\n            || !TEST_BN_ge_zero(bn)\n            || !TEST_BN_eq_one(bn)\n            || !TEST_BN_odd(bn))\n        goto err;\n    BN_free(bn);\n    bn = NULL;\n    if (!TEST_int_eq(parsedecBN(&bn, "-0"), 2)\n            || !TEST_BN_eq_zero(bn)\n            || !TEST_BN_ge_zero(bn)\n            || !TEST_BN_le_zero(bn)\n            || !TEST_BN_even(bn))\n        goto err;\n    BN_free(bn);\n    bn = NULL;\n    if (!TEST_int_eq(parsedecBN(&bn, "42trailing garbage is ignored"), 2)\n            || !TEST_BN_abs_eq_word(bn, 42)\n            || !TEST_BN_ge_zero(bn)\n            || !TEST_BN_gt_zero(bn)\n            || !TEST_BN_ne_zero(bn)\n            || !TEST_BN_even(bn))\n        goto err;\n    st = 1;\nerr:\n    BN_free(bn);\n    return st;\n}', 'static int parsedecBN(BIGNUM **out, const char *in)\n{\n    *out = NULL;\n    return BN_dec2bn(out, in);\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) && isdigit((unsigned char)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}"]