engines/ccgost/gost_sign.c:121: error: UNINITIALIZED_VALUE
  The value read from newsig was never initialized.
Showing all 1 steps of the trace


engines/ccgost/gost_sign.c:121:16: 
119.           BN_CTX_free(ctx);
120.       }
121. >     if(!ret && newsig) {
122.           DSA_SIG_free(newsig);
123.       }

DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
{
    BIGNUM *k = NULL, *tmp = NULL, *tmp2 = NULL;
    DSA_SIG *newsig, *ret = NULL;
    BIGNUM *md = hashsum2bn(dgst);
    BN_CTX *ctx = BN_CTX_new();
    if(!ctx) {
        GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    BN_CTX_start(ctx);
    newsig = DSA_SIG_new();
    if (!newsig) {
        GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    tmp = BN_CTX_get(ctx);
    k = BN_CTX_get(ctx);
    tmp2 = BN_CTX_get(ctx);
    if(!tmp || !k || !tmp2) {
        GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    BN_mod(tmp, md, dsa->q, ctx);
    if (BN_is_zero(tmp)) {
        BN_one(md);
    }
    do {
        do {
            BN_rand_range(k, dsa->q);
            BN_mod_exp(tmp, dsa->g, k, dsa->p, ctx);
            if (!(newsig->r)) {
                newsig->r = BN_new();
                if(!newsig->r) {
                    GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);
                    goto err;
                }
            }
            BN_mod(newsig->r, tmp, dsa->q, ctx);
        }
        while (BN_is_zero(newsig->r));
        BN_mod_mul(tmp, dsa->priv_key, newsig->r, dsa->q, ctx);
        BN_mod_mul(tmp2, k, md, dsa->q, ctx);
        if (!newsig->s) {
            newsig->s = BN_new();
            if(!newsig->s) {
                GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);
                goto err;
            }
        }
        BN_mod_add(newsig->s, tmp, tmp2, dsa->q, ctx);
    }
    while (BN_is_zero(newsig->s));
    ret = newsig;
 err:
    BN_free(md);
    if(ctx) {
        BN_CTX_end(ctx);
        BN_CTX_free(ctx);
    }
    if(!ret && newsig) {
        DSA_SIG_free(newsig);
    }
    return ret;
}
['DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)\n{\n    BIGNUM *k = NULL, *tmp = NULL, *tmp2 = NULL;\n    DSA_SIG *newsig, *ret = NULL;\n    BIGNUM *md = hashsum2bn(dgst);\n    BN_CTX *ctx = BN_CTX_new();\n    if(!ctx) {\n        GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    BN_CTX_start(ctx);\n    newsig = DSA_SIG_new();\n    if (!newsig) {\n        GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    tmp = BN_CTX_get(ctx);\n    k = BN_CTX_get(ctx);\n    tmp2 = BN_CTX_get(ctx);\n    if(!tmp || !k || !tmp2) {\n        GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    BN_mod(tmp, md, dsa->q, ctx);\n    if (BN_is_zero(tmp)) {\n        BN_one(md);\n    }\n    do {\n        do {\n            BN_rand_range(k, dsa->q);\n            BN_mod_exp(tmp, dsa->g, k, dsa->p, ctx);\n            if (!(newsig->r)) {\n                newsig->r = BN_new();\n                if(!newsig->r) {\n                    GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);\n                    goto err;\n                }\n            }\n            BN_mod(newsig->r, tmp, dsa->q, ctx);\n        }\n        while (BN_is_zero(newsig->r));\n        BN_mod_mul(tmp, dsa->priv_key, newsig->r, dsa->q, ctx);\n        BN_mod_mul(tmp2, k, md, dsa->q, ctx);\n        if (!newsig->s) {\n            newsig->s = BN_new();\n            if(!newsig->s) {\n                GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n        }\n        BN_mod_add(newsig->s, tmp, tmp2, dsa->q, ctx);\n    }\n    while (BN_is_zero(newsig->s));\n    ret = newsig;\n err:\n    BN_free(md);\n    if(ctx) {\n        BN_CTX_end(ctx);\n        BN_CTX_free(ctx);\n    }\n    if(!ret && newsig) {\n        DSA_SIG_free(newsig);\n    }\n    return ret;\n}']