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


test/srptest.c:148:5: Call
146.       if (!TEST_ptr(GN = SRP_get_default_gN("1024")))
147.           goto err;
148.       BN_hex2bn(&s, "BEB25379D1A8581EB5A727673A2441EE");
           ^
149.       /* Set up server's password entry */
150.       if (!TEST_true(SRP_create_verifier_BN("alice", "password123", &s, &v, GN->N,

crypto/bn/bn_conv.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_conv.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_conv.c:126:1: <Length trace>
124.   #endif
125.   
126. > int BN_hex2bn(BIGNUM **bn, const char *a)
127.   {
128.       BIGNUM *ret = NULL;

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

crypto/bn/bn_conv.c:141:37: Array access: Offset: [0, 536870912] (⇐ [0, 1] + [0, 536870911]) Size: 33 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 run_srp_kat(void)\n{\n    int ret = 0;\n    BIGNUM *s = NULL;\n    BIGNUM *v = NULL;\n    BIGNUM *a = NULL;\n    BIGNUM *b = NULL;\n    BIGNUM *u = NULL;\n    BIGNUM *x = NULL;\n    BIGNUM *Apub = NULL;\n    BIGNUM *Bpub = NULL;\n    BIGNUM *Kclient = NULL;\n    BIGNUM *Kserver = NULL;\n    const SRP_gN *GN;\n    if (!TEST_ptr(GN = SRP_get_default_gN("1024")))\n        goto err;\n    BN_hex2bn(&s, "BEB25379D1A8581EB5A727673A2441EE");\n    if (!TEST_true(SRP_create_verifier_BN("alice", "password123", &s, &v, GN->N,\n                                          GN->g)))\n        goto err;\n    TEST_info("checking v");\n    if (!TEST_true(check_bn("v", v,\n                 "7E273DE8696FFC4F4E337D05B4B375BEB0DDE1569E8FA00A9886D812"\n                 "9BADA1F1822223CA1A605B530E379BA4729FDC59F105B4787E5186F5"\n                 "C671085A1447B52A48CF1970B4FB6F8400BBF4CEBFBB168152E08AB5"\n                 "EA53D15C1AFF87B2B9DA6E04E058AD51CC72BFC9033B564E26480D78"\n                 "E955A5E29E7AB245DB2BE315E2099AFB")))\n        goto err;\n    TEST_note("    okay");\n    BN_hex2bn(&b, "E487CB59D31AC550471E81F00F6928E01DDA08E974A004F49E61F5D1"\n                  "05284D20");\n    Bpub = SRP_Calc_B(b, GN->N, GN->g, v);\n    if (!TEST_true(SRP_Verify_B_mod_N(Bpub, GN->N)))\n        goto err;\n    TEST_info("checking B");\n    if (!TEST_true(check_bn("B", Bpub,\n                  "BD0C61512C692C0CB6D041FA01BB152D4916A1E77AF46AE105393011"\n                  "BAF38964DC46A0670DD125B95A981652236F99D9B681CBF87837EC99"\n                  "6C6DA04453728610D0C6DDB58B318885D7D82C7F8DEB75CE7BD4FBAA"\n                  "37089E6F9C6059F388838E7A00030B331EB76840910440B1B27AAEAE"\n                  "EB4012B7D7665238A8E3FB004B117B58")))\n        goto err;\n    TEST_note("    okay");\n    BN_hex2bn(&a, "60975527035CF2AD1989806F0407210BC81EDC04E2762A56AFD529DD"\n                  "DA2D4393");\n    Apub = SRP_Calc_A(a, GN->N, GN->g);\n    if (!TEST_true(SRP_Verify_A_mod_N(Apub, GN->N)))\n        goto err;\n    TEST_info("checking A");\n    if (!TEST_true(check_bn("A", Apub,\n                  "61D5E490F6F1B79547B0704C436F523DD0E560F0C64115BB72557EC4"\n                  "4352E8903211C04692272D8B2D1A5358A2CF1B6E0BFCF99F921530EC"\n                  "8E39356179EAE45E42BA92AEACED825171E1E8B9AF6D9C03E1327F44"\n                  "BE087EF06530E69F66615261EEF54073CA11CF5858F0EDFDFE15EFEA"\n                  "B349EF5D76988A3672FAC47B0769447B")))\n        goto err;\n    TEST_note("    okay");\n    u = SRP_Calc_u(Apub, Bpub, GN->N);\n    if (!TEST_true(check_bn("u", u,\n                    "CE38B9593487DA98554ED47D70A7AE5F462EF019")))\n        goto err;\n    x = SRP_Calc_x(s, "alice", "password123");\n    Kclient = SRP_Calc_client_key(GN->N, Bpub, GN->g, x, a, u);\n    TEST_info("checking client\'s key");\n    if (!TEST_true(check_bn("Client\'s key", Kclient,\n                  "B0DC82BABCF30674AE450C0287745E7990A3381F63B387AAF271A10D"\n                  "233861E359B48220F7C4693C9AE12B0A6F67809F0876E2D013800D6C"\n                  "41BB59B6D5979B5C00A172B4A2A5903A0BDCAF8A709585EB2AFAFA8F"\n                  "3499B200210DCC1F10EB33943CD67FC88A2F39A4BE5BEC4EC0A3212D"\n                  "C346D7E474B29EDE8A469FFECA686E5A")))\n        goto err;\n    TEST_note("    okay");\n    Kserver = SRP_Calc_server_key(Apub, v, u, b, GN->N);\n    TEST_info("checking server\'s key");\n    if (!TEST_true(check_bn("Server\'s key", Kserver,\n                  "B0DC82BABCF30674AE450C0287745E7990A3381F63B387AAF271A10D"\n                  "233861E359B48220F7C4693C9AE12B0A6F67809F0876E2D013800D6C"\n                  "41BB59B6D5979B5C00A172B4A2A5903A0BDCAF8A709585EB2AFAFA8F"\n                  "3499B200210DCC1F10EB33943CD67FC88A2F39A4BE5BEC4EC0A3212D"\n                  "C346D7E474B29EDE8A469FFECA686E5A")))\n        goto err;\n    TEST_note("    okay");\n    ret = 1;\nerr:\n    BN_clear_free(Kclient);\n    BN_clear_free(Kserver);\n    BN_clear_free(x);\n    BN_free(u);\n    BN_free(Apub);\n    BN_clear_free(a);\n    BN_free(Bpub);\n    BN_clear_free(b);\n    BN_free(s);\n    BN_clear_free(v);\n    return ret;\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}"]