test/bntest.c:1009: error: BUFFER_OVERRUN_L2
  Offset: [0, 536870912] (⇐ [0, 1] + [0, 536870911]) Size: 3 by call to `BN_hex2bn`.
Showing all 6 steps of the trace


test/bntest.c:1009:5: Call
1007.       /* Regression test for carry propagation bug in sqr8x_reduction */
1008.       BN_hex2bn(&a, "050505050505");
1009.       BN_hex2bn(&b, "02");
            ^
1010.       BN_hex2bn(&c,
1011.           "4141414141414141414141274141414141414141414141414141414141414141"

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: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:139:37: Array access: Offset: [0, 536870912] (⇐ [0, 1] + [0, 536870911]) Size: 3 by call to `BN_hex2bn` 
  137.       }
  138.   
  139.       for (i = 0; i <= (INT_MAX/4) && isxdigit((unsigned char)a[i]); i++)
                                             ^
  140.           continue;
  141.   

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);
    ret->neg = neg;
    *bn = ret;
    bn_check_top(ret);
    return (num);
 err:
    if (*bn == NULL)
        BN_free(ret);
    return (0);
}
['int test_mod_exp(BIO *bp, BN_CTX *ctx)\n{\n    BIGNUM *a, *b, *c, *d, *e;\n    int i;\n    a = BN_new();\n    b = BN_new();\n    c = BN_new();\n    d = BN_new();\n    e = BN_new();\n    BN_one(a);\n    BN_one(b);\n    BN_zero(c);\n    if (BN_mod_exp(d, a, b, c, ctx)) {\n        fprintf(stderr, "BN_mod_exp with zero modulus succeeded!\\n");\n        return 0;\n    }\n    BN_bntest_rand(c, 30, 0, 1);\n    for (i = 0; i < num2; i++) {\n        BN_bntest_rand(a, 20 + i * 5, 0, 0);\n        BN_bntest_rand(b, 2 + i, 0, 0);\n        if (!BN_mod_exp(d, a, b, c, ctx))\n            return (0);\n        if (bp != NULL) {\n            if (!results) {\n                BN_print(bp, a);\n                BIO_puts(bp, " ^ ");\n                BN_print(bp, b);\n                BIO_puts(bp, " % ");\n                BN_print(bp, c);\n                BIO_puts(bp, " - ");\n            }\n            BN_print(bp, d);\n            BIO_puts(bp, "\\n");\n        }\n        BN_exp(e, a, b, ctx);\n        BN_sub(e, e, d);\n        BN_div(a, b, e, c, ctx);\n        if (!BN_is_zero(b)) {\n            fprintf(stderr, "Modulo exponentiation test failed!\\n");\n            return 0;\n        }\n    }\n    BN_hex2bn(&a, "050505050505");\n    BN_hex2bn(&b, "02");\n    BN_hex2bn(&c,\n        "4141414141414141414141274141414141414141414141414141414141414141"\n        "4141414141414141414141414141414141414141414141414141414141414141"\n        "4141414141414141414141800000000000000000000000000000000000000000"\n        "0000000000000000000000000000000000000000000000000000000000000000"\n        "0000000000000000000000000000000000000000000000000000000000000000"\n        "0000000000000000000000000000000000000000000000000000000001");\n    BN_mod_exp(d, a, b, c, ctx);\n    BN_mul(e, a, a, ctx);\n    if (BN_cmp(d, e)) {\n        fprintf(stderr, "BN_mod_exp and BN_mul produce different results!\\n");\n        return 0;\n    }\n    BN_free(a);\n    BN_free(b);\n    BN_free(c);\n    BN_free(d);\n    BN_free(e);\n    return (1);\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    ret->neg = neg;\n    *bn = ret;\n    bn_check_top(ret);\n    return (num);\n err:\n    if (*bn == NULL)\n        BN_free(ret);\n    return (0);\n}"]