test/bntest.c:1029: error: BUFFER_OVERRUN_L3
  Offset: [-15, +oo] (⇐ [0, 1] + [-15, +oo]) Size: 3 by call to `BN_hex2bn`.
Showing all 7 steps of the trace


test/bntest.c:1029:5: Call
1027.       /* Regression test for carry propagation bug in sqr8x_reduction */
1028.       BN_hex2bn(&a, "050505050505");
1029.       BN_hex2bn(&b, "02");
            ^
1030.       BN_hex2bn(&c,
1031.           "4141414141414141414141274141414141414141414141414141414141414141"

crypto/bn/bn_print.c:187:10: <Offset trace>
185.       }
186.   
187.       for (i = 0; isxdigit((unsigned char)a[i]); i++) ;
                ^
188.   
189.       num = i + neg;

crypto/bn/bn_print.c:187:10: Assignment
  185.       }
  186.   
  187.       for (i = 0; isxdigit((unsigned char)a[i]); i++) ;
                  ^
  188.   
  189.       num = i + neg;

crypto/bn/bn_print.c:206:5: Assignment
  204.           goto err;
  205.   
  206.       j = i;                      /* least significant 'hex' */
             ^
  207.       m = 0;
  208.       h = 0;

crypto/bn/bn_print.c:172:1: <Length trace>
170.   }
171.   
172. > int BN_hex2bn(BIGNUM **bn, const char *a)
173.   {
174.       BIGNUM *ret = NULL;

crypto/bn/bn_print.c:172:1: Parameter `*a`
  170.   }
  171.   
  172. > int BN_hex2bn(BIGNUM **bn, const char *a)
  173.   {
  174.       BIGNUM *ret = NULL;

crypto/bn/bn_print.c:213:17: Array access: Offset: [-15, +oo] (⇐ [0, 1] + [-15, +oo]) Size: 3 by call to `BN_hex2bn` 
  211.           l = 0;
  212.           for (;;) {
  213.               c = a[j - m];
                         ^
  214.               if ((c >= '0') && (c <= '9'))
  215.                   k = c - '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; isxdigit((unsigned char)a[i]); i++) ;
    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];
            if ((c >= '0') && (c <= '9'))
                k = c - '0';
            else if ((c >= 'a') && (c <= 'f'))
                k = c - 'a' + 10;
            else if ((c >= 'A') && (c <= 'F'))
                k = c - 'A' + 10;
            else
                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; isxdigit((unsigned char)a[i]); i++) ;\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            if ((c >= '0') && (c <= '9'))\n                k = c - '0';\n            else if ((c >= 'a') && (c <= 'f'))\n                k = c - 'a' + 10;\n            else if ((c >= 'A') && (c <= 'F'))\n                k = c - 'A' + 10;\n            else\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}"]