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


test/ectest.c:983:13: Call
981.           || !TEST_ptr(b = BN_new())
982.           || !TEST_true(BN_hex2bn(&p, "13"))
983.           || !TEST_true(BN_hex2bn(&a, "3"))
                   ^
984.           || !TEST_true(BN_hex2bn(&b, "1")))
985.           goto err;

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

crypto/bn/bn_print.c:141:10: Assignment
  139.       }
  140.   
  141.       for (i = 0; i <= INT_MAX / 4 && ossl_isxdigit(a[i]); i++)
                  ^
  142.           continue;
  143.   

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

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

crypto/bn/bn_print.c:141:37: Array access: Offset: [0, 536870912] (⇐ [0, 1] + [0, 536870911]) Size: 2 by call to `BN_hex2bn` 
  139.       }
  140.   
  141.       for (i = 0; i <= INT_MAX / 4 && ossl_isxdigit(a[i]); i++)
                                             ^
  142.           continue;
  143.   

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 && ossl_isxdigit(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 char2_field_tests(void)\n{\n    BN_CTX *ctx = NULL;\n    BIGNUM *p = NULL, *a = NULL, *b = NULL;\n    EC_GROUP *group = NULL, *tmp = NULL;\n    EC_POINT *P = NULL, *Q = NULL, *R = NULL;\n    BIGNUM *x = NULL, *y = NULL, *z = NULL, *cof = NULL, *yplusone = NULL;\n    unsigned char buf[100];\n    size_t len;\n    int k, r = 0;\n    if (!TEST_ptr(ctx = BN_CTX_new())\n        || !TEST_ptr(p = BN_new())\n        || !TEST_ptr(a = BN_new())\n        || !TEST_ptr(b = BN_new())\n        || !TEST_true(BN_hex2bn(&p, "13"))\n        || !TEST_true(BN_hex2bn(&a, "3"))\n        || !TEST_true(BN_hex2bn(&b, "1")))\n        goto err;\n    group = EC_GROUP_new(EC_GF2m_simple_method());\n    if (!TEST_ptr(group)\n        || !TEST_true(EC_GROUP_set_curve_GF2m(group, p, a, b, ctx))\n        || !TEST_ptr(tmp = EC_GROUP_new(EC_GROUP_method_of(group)))\n        || !TEST_true(EC_GROUP_copy(tmp, group)))\n        goto err;\n    EC_GROUP_free(group);\n    group = tmp;\n    tmp = NULL;\n    if (!TEST_true(EC_GROUP_get_curve_GF2m(group, p, a, b, ctx)))\n        goto err;\n    TEST_info("Curve defined by Weierstrass equation");\n    TEST_note("     y^2 + x*y = x^3 + a*x^2 + b (mod p)");\n    test_output_bignum("a", a);\n    test_output_bignum("b", b);\n    test_output_bignum("p", p);\n     if (!TEST_ptr(P = EC_POINT_new(group))\n        || !TEST_ptr(Q = EC_POINT_new(group))\n        || !TEST_ptr(R = EC_POINT_new(group))\n        || !TEST_true(EC_POINT_set_to_infinity(group, P))\n        || !TEST_true(EC_POINT_is_at_infinity(group, P)))\n        goto err;\n    buf[0] = 0;\n    if (!TEST_true(EC_POINT_oct2point(group, Q, buf, 1, ctx))\n        || !TEST_true(EC_POINT_add(group, P, P, Q, ctx))\n        || !TEST_true(EC_POINT_is_at_infinity(group, P))\n        || !TEST_ptr(x = BN_new())\n        || !TEST_ptr(y = BN_new())\n        || !TEST_ptr(z = BN_new())\n        || !TEST_ptr(cof = BN_new())\n        || !TEST_ptr(yplusone = BN_new())\n        || !TEST_true(BN_hex2bn(&x, "6"))\n#  ifdef OPENSSL_EC_BIN_PT_COMP\n        || !TEST_true(EC_POINT_set_compressed_coordinates_GF2m(group, Q, x, 1,\n                                                               ctx))\n#  else\n        || !TEST_true(BN_hex2bn(&y, "8"))\n        || !TEST_true(EC_POINT_set_affine_coordinates_GF2m(group, Q, x, y, ctx))\n#  endif\n       )\n        goto err;\n    if (!TEST_int_gt(EC_POINT_is_on_curve(group, Q, ctx), 0)) {\n#  ifdef OPENSSL_EC_BIN_PT_COMP\n        if (!TEST_true(EC_POINT_get_affine_coordinates_GF2m(group, Q, x, y,\n                                                            ctx)))\n            goto err;\n#  endif\n        TEST_info("Point is not on curve");\n        test_output_bignum("x", x);\n        test_output_bignum("y", y);\n        goto err;\n    }\n    TEST_note("A cyclic subgroup:");\n    k = 100;\n    do {\n        if (!TEST_int_ne(k--, 0))\n            goto err;\n        if (EC_POINT_is_at_infinity(group, P))\n            TEST_note("     point at infinity");\n        else {\n            if (!TEST_true(EC_POINT_get_affine_coordinates_GF2m(group, P, x, y,\n                                                                ctx)))\n                goto err;\n            test_output_bignum("x", x);\n            test_output_bignum("y", y);\n        }\n        if (!TEST_true(EC_POINT_copy(R, P))\n            || !TEST_true(EC_POINT_add(group, P, P, Q, ctx)))\n            goto err;\n    }\n    while (!EC_POINT_is_at_infinity(group, P));\n    if (!TEST_true(EC_POINT_add(group, P, Q, R, ctx))\n        || !TEST_true(EC_POINT_is_at_infinity(group, P)))\n        goto err;\n#  ifdef OPENSSL_EC_BIN_PT_COMP\n    len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED,\n                             buf, sizeof buf, ctx);\n    if (!TEST_size_t_ne(len, 0)\n        || !TEST_true(EC_POINT_oct2point(group, P, buf, len, ctx))\n        || !TEST_int_eq(0, EC_POINT_cmp(group, P, Q, ctx)))\n        goto err;\n    test_output_memory("Generator as octet string, compressed form:",\n                       buf, len);\n#  endif\n    len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED,\n                             buf, sizeof buf, ctx);\n    if (!TEST_size_t_ne(len, 0)\n        || !TEST_true(EC_POINT_oct2point(group, P, buf, len, ctx))\n        || !TEST_int_eq(0, EC_POINT_cmp(group, P, Q, ctx)))\n        goto err;\n    test_output_memory("Generator as octet string, uncompressed form:",\n                       buf, len);\n#  ifdef OPENSSL_EC_BIN_PT_COMP\n    len =\n        EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf,\n                           ctx);\n    if (!TEST_size_t_ne(len, 0)\n        || !TEST_true(EC_POINT_oct2point(group, P, buf, len, ctx))\n        || !TEST_int_eq(0, EC_POINT_cmp(group, P, Q, ctx)))\n        goto err;\n    test_output_memory("Generator as octet string, hybrid form:",\n                       buf, len);\n#  endif\n    if (!TEST_true(EC_POINT_invert(group, P, ctx))\n        || !TEST_int_eq(0, EC_POINT_cmp(group, P, R, ctx)))\n        goto err;\n    TEST_note("\\n");\n    r = 1;\nerr:\n    BN_CTX_free(ctx);\n    BN_free(p);\n    BN_free(a);\n    BN_free(b);\n    EC_GROUP_free(group);\n    EC_GROUP_free(tmp);\n    EC_POINT_free(P);\n    EC_POINT_free(Q);\n    EC_POINT_free(R);\n    BN_free(x);\n    BN_free(y);\n    BN_free(z);\n    BN_free(cof);\n    BN_free(yplusone);\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 && ossl_isxdigit(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}"]