test/bntest.c:1623: error: BUFFER_OVERRUN_L2
  Offset: [0, 536870913] (⇐ [0, 2] + [0, 536870911]) Size: 2 by call to `BN_asc2bn`.
Showing all 9 steps of the trace


test/bntest.c:1623:10: Call
1621.           goto err;
1622.   
1623.       if (!TEST_true(BN_asc2bn(&bn, "0"))
                 ^
1624.               || !TEST_true(BN_is_zero(bn))
1625.               || !TEST_false(BN_is_negative(bn)))

crypto/bn/bn_print.c:269:1: Parameter `*a`
  267.   }
  268.   
  269. > int BN_asc2bn(BIGNUM **bn, const char *a)
  270.   {
  271.       const char *p = a;

crypto/bn/bn_print.c:271:5: Assignment
  269.   int BN_asc2bn(BIGNUM **bn, const char *a)
  270.   {
  271.       const char *p = a;
             ^
  272.   
  273.       if (*p == '-')

crypto/bn/bn_print.c:280:14: Call
  278.               return 0;
  279.       } else {
  280.           if (!BN_dec2bn(bn, p))
                      ^
  281.               return 0;
  282.       }

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

crypto/bn/bn_print.c:213:10: Assignment
    211.       }
    212.   
    213.       for (i = 0; i <= (INT_MAX/4) && isdigit((unsigned char)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, 536870913] (⇐ [0, 2] + [0, 536870911]) Size: 2 by call to `BN_asc2bn` 
    211.       }
    212.   
    213.       for (i = 0; i <= (INT_MAX/4) && isdigit((unsigned char)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) && 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_asc2bn()\n{\n    BIGNUM *bn = NULL;\n    int st = 0;\n    if (!TEST_ptr(bn = BN_new()))\n        goto err;\n    if (!TEST_true(BN_asc2bn(&bn, "0"))\n            || !TEST_true(BN_is_zero(bn))\n            || !TEST_false(BN_is_negative(bn)))\n        goto err;\n    if (!TEST_true(BN_asc2bn(&bn, "256"))\n            || !TEST_true(BN_is_word(bn, 256))\n            || !TEST_false(BN_is_negative(bn)))\n        goto err;\n    if (!TEST_true(BN_asc2bn(&bn, "-42"))\n            || !TEST_true(BN_abs_is_word(bn, 42))\n            || !TEST_true(BN_is_negative(bn)))\n        goto err;\n    if (!TEST_true(BN_asc2bn(&bn, "0x1234"))\n            || !TEST_true(BN_is_word(bn, 0x1234))\n            || !TEST_false(BN_is_negative(bn)))\n        goto err;\n    if (!TEST_true(BN_asc2bn(&bn, "0X1234"))\n            || !TEST_true(BN_is_word(bn, 0x1234))\n            || !TEST_false(BN_is_negative(bn)))\n        goto err;\n    if (!TEST_true(BN_asc2bn(&bn, "-0xabcd"))\n            || !TEST_true(BN_abs_is_word(bn, 0xabcd))\n            || !TEST_true(BN_is_negative(bn)))\n        goto err;\n    if (!TEST_true(BN_asc2bn(&bn, "-0"))\n            || !TEST_true(BN_is_zero(bn))\n            || !TEST_false(BN_is_negative(bn)))\n        goto err;\n    if (!TEST_true(BN_asc2bn(&bn, "123trailing garbage is ignored"))\n            || !TEST_true(BN_is_word(bn, 123))\n            || !TEST_false(BN_is_negative(bn)))\n        goto err;\n    st = 1;\nerr:\n    BN_free(bn);\n    return st;\n}', "int BN_asc2bn(BIGNUM **bn, const char *a)\n{\n    const char *p = a;\n    if (*p == '-')\n        p++;\n    if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) {\n        if (!BN_hex2bn(bn, p + 2))\n            return 0;\n    } else {\n        if (!BN_dec2bn(bn, p))\n            return 0;\n    }\n    if (*a == '-' && (*bn)->top != 0)\n        (*bn)->neg = 1;\n    return 1;\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}"]