test/test_test.c:406: error: BUFFER_OVERRUN_L2
  Offset: [-15, 536870911] (⇐ [0, 1] + [-15, 536870910]) Size: 65 by call to `BN_hex2bn`.
Showing all 8 steps of the trace


test/test_test.c:380:1: Array declaration
378.   }
379.   
380. > static int test_long_bignum(void)
381.   {
382.       int r;

test/test_test.c:406:12: Call
404.           && TEST_true(BN_hex2bn(&b, bs))
405.           && TEST_true(BN_hex2bn(&c, cs))
406.           && TEST_true(BN_hex2bn(&d, ds))
                  ^
407.           && (TEST(0, TEST_BN_eq(a, b))
408.               & TEST(0, TEST_BN_eq(b, a))

crypto/bn/bn_print.c:139:10: <Offset trace>
137.       }
138.   
139.       for (i = 0; i <= (INT_MAX/4) && isxdigit((unsigned char)a[i]); i++)
                ^
140.           continue;
141.   

crypto/bn/bn_print.c:139:10: Assignment
  137.       }
  138.   
  139.       for (i = 0; i <= (INT_MAX/4) && isxdigit((unsigned char)a[i]); i++)
                  ^
  140.           continue;
  141.   

crypto/bn/bn_print.c:162:5: Assignment
  160.           goto err;
  161.   
  162.       j = i;                      /* least significant 'hex' */
             ^
  163.       m = 0;
  164.       h = 0;

crypto/bn/bn_print.c:124:1: <Length trace>
122.   }
123.   
124. > int BN_hex2bn(BIGNUM **bn, const char *a)
125.   {
126.       BIGNUM *ret = NULL;

crypto/bn/bn_print.c:124:1: Parameter `*a`
  122.   }
  123.   
  124. > int BN_hex2bn(BIGNUM **bn, const char *a)
  125.   {
  126.       BIGNUM *ret = NULL;

crypto/bn/bn_print.c:169:17: Array access: Offset: [-15, 536870911] (⇐ [0, 1] + [-15, 536870910]) Size: 65 by call to `BN_hex2bn` 
  167.           l = 0;
  168.           for (;;) {
  169.               c = a[j - m];
                         ^
  170.               k = OPENSSL_hexchar2int(c);
  171.               if (k < 0)

int BN_hex2bn(BIGNUM **bn, const char *a)
{
    BIGNUM *ret = NULL;
    BN_ULONG l = 0;
    int neg = 0, h, m, i, j, k, c;
    int num;
    if ((a == NULL) || (*a == '\0'))
        return (0);
    if (*a == '-') {
        neg = 1;
        a++;
    }
    for (i = 0; i <= (INT_MAX/4) && isxdigit((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 = i;
    m = 0;
    h = 0;
    while (j > 0) {
        m = ((BN_BYTES * 2) <= j) ? (BN_BYTES * 2) : j;
        l = 0;
        for (;;) {
            c = a[j - m];
            k = OPENSSL_hexchar2int(c);
            if (k < 0)
                k = 0;
            l = (l << 4) | k;
            if (--m <= 0) {
                ret->d[h++] = l;
                break;
            }
        }
        j -= (BN_BYTES * 2);
    }
    ret->top = h;
    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_long_bignum(void)\n{\n    int r;\n    BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL;\n    const char as[] = "1234567890123456789012345678901234567890123456789012"\n                      "1234567890123456789012345678901234567890123456789012"\n                      "1234567890123456789012345678901234567890123456789012"\n                      "1234567890123456789012345678901234567890123456789012"\n                      "1234567890123456789012345678901234567890123456789012"\n                      "1234567890123456789012345678901234567890123456789012"\n                      "FFFFFF";\n    const char bs[] = "1234567890123456789012345678901234567890123456789012"\n                      "1234567890123456789012345678901234567890123456789013"\n                      "987657";\n    const char cs[] = "-"\n                      "123456789012345678901234567890"\n                      "123456789012345678901234567890"\n                      "ABCD";\n    const char ds[] = "-"\n                      "23456789A123456789B123456789C"\n                      "123456789D123456789E123456789F"\n                      "ABCD";\n    r = TEST_true(BN_hex2bn(&a, as))\n        && TEST_true(BN_hex2bn(&b, bs))\n        && TEST_true(BN_hex2bn(&c, cs))\n        && TEST_true(BN_hex2bn(&d, ds))\n        && (TEST(0, TEST_BN_eq(a, b))\n            & TEST(0, TEST_BN_eq(b, a))\n            & TEST(0, TEST_BN_eq(b, NULL))\n            & TEST(0, TEST_BN_eq(NULL, a))\n            & TEST(1, TEST_BN_ne(a, NULL))\n            & TEST(0, TEST_BN_eq(c, d)));\n    BN_free(a);\n    BN_free(b);\n    BN_free(c);\n    BN_free(d);\n    return r;\n}', "int BN_hex2bn(BIGNUM **bn, const char *a)\n{\n    BIGNUM *ret = NULL;\n    BN_ULONG l = 0;\n    int neg = 0, h, m, i, j, k, c;\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) && isxdigit((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 = i;\n    m = 0;\n    h = 0;\n    while (j > 0) {\n        m = ((BN_BYTES * 2) <= j) ? (BN_BYTES * 2) : j;\n        l = 0;\n        for (;;) {\n            c = a[j - m];\n            k = OPENSSL_hexchar2int(c);\n            if (k < 0)\n                k = 0;\n            l = (l << 4) | k;\n            if (--m <= 0) {\n                ret->d[h++] = l;\n                break;\n            }\n        }\n        j -= (BN_BYTES * 2);\n    }\n    ret->top = h;\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}"]