engines/ccgost/gost2001.c:66: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_hex2bn`.
Showing all 9 steps of the trace


engines/ccgost/gost2001.c:49:9: Call
47.   
48.       BN_CTX_start(ctx);
49.       p = BN_CTX_get(ctx);
              ^
50.       a = BN_CTX_get(ctx);
51.       b = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:284:5: Call
  282.       }
  283.       /* OK, make sure the returned bignum is "zero" */
  284.       BN_zero(ret);
             ^
  285.       ctx->used++;
  286.       CTXDBG_RET(ctx, ret);

crypto/bn/bn_lib.c:530:1: Parameter `*a->d`
    528.   }
    529.   
    530. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    531.   {
    532.       bn_check_top(a);

engines/ccgost/gost2001.c:66:10: Call
64.           goto err;
65.       }
66.       if (!BN_hex2bn(&p, params->p)
               ^
67.           || !BN_hex2bn(&a, params->a)
68.           || !BN_hex2bn(&b, params->b)) {

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

crypto/bn/bn_print.c:199:9: Call
  197.       } else {
  198.           ret = *bn;
  199.           BN_zero(ret);
                 ^
  200.       }
  201.   

crypto/bn/bn_lib.c:530:1: <Length trace>
528.   }
529.   
530. > int BN_set_word(BIGNUM *a, BN_ULONG w)
531.   {
532.       bn_check_top(a);

crypto/bn/bn_lib.c:530:1: Parameter `*a->d`
    528.   }
    529.   
    530. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    531.   {
    532.       bn_check_top(a);

crypto/bn/bn_lib.c:536:5: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_hex2bn` 
    534.           return (0);
    535.       a->neg = 0;
    536.       a->d[0] = w;
               ^
    537.       a->top = (w ? 1 : 0);
    538.       bn_check_top(a);

int BN_set_word(BIGNUM *a, BN_ULONG w)
{
    bn_check_top(a);
    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
        return (0);
    a->neg = 0;
    a->d[0] = w;
    a->top = (w ? 1 : 0);
    bn_check_top(a);
    return (1);
}
['int fill_GOST2001_params(EC_KEY *eckey, int nid)\n{\n    R3410_2001_params *params = R3410_2001_paramset;\n    EC_GROUP *grp = NULL;\n    BIGNUM *p = NULL, *q = NULL, *a = NULL, *b = NULL, *x = NULL, *y = NULL;\n    EC_POINT *P = NULL;\n    BN_CTX *ctx = BN_CTX_new();\n    int ok = 0;\n    if (!ctx) {\n        GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    BN_CTX_start(ctx);\n    p = BN_CTX_get(ctx);\n    a = BN_CTX_get(ctx);\n    b = BN_CTX_get(ctx);\n    x = BN_CTX_get(ctx);\n    y = BN_CTX_get(ctx);\n    q = BN_CTX_get(ctx);\n    if (!p || !a || !b || !x || !y || !q) {\n        GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    while (params->nid != NID_undef && params->nid != nid)\n        params++;\n    if (params->nid == NID_undef) {\n        GOSTerr(GOST_F_FILL_GOST2001_PARAMS,\n                GOST_R_UNSUPPORTED_PARAMETER_SET);\n        goto err;\n    }\n    if (!BN_hex2bn(&p, params->p)\n        || !BN_hex2bn(&a, params->a)\n        || !BN_hex2bn(&b, params->b)) {\n        GOSTerr(GOST_F_FILL_GOST2001_PARAMS,\n                ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    grp = EC_GROUP_new_curve_GFp(p, a, b, ctx);\n    if (!grp)  {\n        GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    P = EC_POINT_new(grp);\n    if (!P)  {\n        GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!BN_hex2bn(&x, params->x)\n        || !BN_hex2bn(&y, params->y)\n        || !EC_POINT_set_affine_coordinates_GFp(grp, P, x, y, ctx)\n        || !BN_hex2bn(&q, params->q))  {\n        GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n#ifdef DEBUG_KEYS\n    fprintf(stderr, "Set params index %d oid %s\\nq=",\n            (params - R3410_2001_paramset), OBJ_nid2sn(params->nid));\n    BN_print_fp(stderr, q);\n    fprintf(stderr, "\\n");\n#endif\n    if (!EC_GROUP_set_generator(grp, P, q, NULL)) {\n        GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    EC_GROUP_set_curve_name(grp, params->nid);\n    if (!EC_KEY_set_group(eckey, grp)) {\n        GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    ok = 1;\n err:\n    EC_POINT_free(P);\n    EC_GROUP_free(grp);\n    if (ctx)\n        BN_CTX_end(ctx);\n    BN_CTX_free(ctx);\n    return ok;\n}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n{\n    BIGNUM *ret;\n    CTXDBG_ENTRY("BN_CTX_get", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        return NULL;\n    if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {\n        ctx->too_many = 1;\n        BNerr(BN_F_BN_CTX_GET, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        return NULL;\n    }\n    BN_zero(ret);\n    ctx->used++;\n    CTXDBG_RET(ctx, ret);\n    return ret;\n}', 'int BN_set_word(BIGNUM *a, BN_ULONG w)\n{\n    bn_check_top(a);\n    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)\n        return (0);\n    a->neg = 0;\n    a->d[0] = w;\n    a->top = (w ? 1 : 0);\n    bn_check_top(a);\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}"]