crypto/dsa/dsa_ameth.c:178: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_mod_exp`.
Showing all 13 steps of the trace


crypto/dsa/dsa_ameth.c:164:13: Call
162.       /* We have parameters now set private key */
163.       if ((dsa->priv_key = BN_secure_new()) == NULL
164.           || !ASN1_INTEGER_to_BN(privkey, dsa->priv_key)) {
                   ^
165.           DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_BN_ERROR);
166.           goto dsaerr;

crypto/asn1/a_int.c:559:12: Call
  557.   BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)
  558.   {
  559.       return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER);
                    ^
  560.   }
  561.   

crypto/asn1/a_int.c:493:1: Parameter `bn->d`
    491.   }
    492.   
    493. > static BIGNUM *asn1_string_to_bn(const ASN1_INTEGER *ai, BIGNUM *bn,
    494.                                    int itype)
    495.   {

crypto/dsa/dsa_ameth.c:178:10: Call
176.       }
177.   
178.       if (!BN_mod_exp(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) {
                ^
179.           DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_BN_ERROR);
180.           goto dsaerr;

crypto/bn/bn_exp.c:88:1: Parameter `*m->d`
  86.   }
  87.   
  88. > int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
  89.                  BN_CTX *ctx)
  90.   {

crypto/bn/bn_exp.c:146:15: Call
  144.   #ifdef RECP_MUL_MOD
  145.       {
  146.           ret = BN_mod_exp_recp(r, a, p, m, ctx);
                       ^
  147.       }
  148.   #else

crypto/bn/bn_exp.c:158:1: Parameter `*m->d`
    156.   }
    157.   
    158. > int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
    159.                       const BIGNUM *m, BN_CTX *ctx)
    160.   {

crypto/bn/bn_exp.c:195:14: Call
    193.       if (m->neg) {
    194.           /* ignore sign of 'm' */
    195.           if (!BN_copy(aa, m))
                        ^
    196.               goto err;
    197.           aa->neg = 0;

crypto/bn/bn_lib.c:323:1: <Offset trace>
321.   }
322.   
323. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
324.   {
325.       bn_check_top(b);

crypto/bn/bn_lib.c:323:1: Parameter `b->top`
      321.   }
      322.   
      323. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
      324.   {
      325.       bn_check_top(b);

crypto/bn/bn_lib.c:323:1: <Length trace>
321.   }
322.   
323. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
324.   {
325.       bn_check_top(b);

crypto/bn/bn_lib.c:323:1: Parameter `*b->d`
      321.   }
      322.   
      323. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
      324.   {
      325.       bn_check_top(b);

crypto/bn/bn_lib.c:333:9: Array access: Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_mod_exp` 
      331.   
      332.       if (b->top > 0)
      333.           memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
                     ^
      334.   
      335.       if (BN_get_flags(b, BN_FLG_CONSTTIME) != 0)

BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
{
    bn_check_top(b);
    if (a == b)
        return a;
    if (bn_wexpand(a, b->top) == NULL)
        return NULL;
    if (b->top > 0)
        memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
    if (BN_get_flags(b, BN_FLG_CONSTTIME) != 0)
        BN_set_flags(a, BN_FLG_CONSTTIME);
    a->top = b->top;
    a->neg = b->neg;
    bn_check_top(a);
    return a;
}
['static int dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)\n{\n    const unsigned char *p, *pm;\n    int pklen, pmlen;\n    int ptype;\n    const void *pval;\n    const ASN1_STRING *pstr;\n    const X509_ALGOR *palg;\n    ASN1_INTEGER *privkey = NULL;\n    BN_CTX *ctx = NULL;\n    DSA *dsa = NULL;\n    int ret = 0;\n    if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8))\n        return 0;\n    X509_ALGOR_get0(NULL, &ptype, &pval, palg);\n    if ((privkey = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL)\n        goto decerr;\n    if (privkey->type == V_ASN1_NEG_INTEGER || ptype != V_ASN1_SEQUENCE)\n        goto decerr;\n    pstr = pval;\n    pm = pstr->data;\n    pmlen = pstr->length;\n    if ((dsa = d2i_DSAparams(NULL, &pm, pmlen)) == NULL)\n        goto decerr;\n    if ((dsa->priv_key = BN_secure_new()) == NULL\n        || !ASN1_INTEGER_to_BN(privkey, dsa->priv_key)) {\n        DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_BN_ERROR);\n        goto dsaerr;\n    }\n    if ((dsa->pub_key = BN_new()) == NULL) {\n        DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE);\n        goto dsaerr;\n    }\n    if ((ctx = BN_CTX_new()) == NULL) {\n        DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE);\n        goto dsaerr;\n    }\n    if (!BN_mod_exp(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) {\n        DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_BN_ERROR);\n        goto dsaerr;\n    }\n    EVP_PKEY_assign_DSA(pkey, dsa);\n    ret = 1;\n    goto done;\n decerr:\n    DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_DECODE_ERROR);\n dsaerr:\n    DSA_free(dsa);\n done:\n    BN_CTX_free(ctx);\n    ASN1_STRING_clear_free(privkey);\n    return ret;\n}', 'BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)\n{\n    return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER);\n}', 'static BIGNUM *asn1_string_to_bn(const ASN1_INTEGER *ai, BIGNUM *bn,\n                                 int itype)\n{\n    BIGNUM *ret;\n    if ((ai->type & ~V_ASN1_NEG) != itype) {\n        ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_WRONG_INTEGER_TYPE);\n        return NULL;\n    }\n    ret = BN_bin2bn(ai->data, ai->length, bn);\n    if (ret == NULL) {\n        ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_BN_LIB);\n        return NULL;\n    }\n    if (ai->type & V_ASN1_NEG)\n        BN_set_negative(ret, 1);\n    return ret;\n}', 'int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    int ret;\n    bn_check_top(a);\n    bn_check_top(p);\n    bn_check_top(m);\n#define MONT_MUL_MOD\n#define MONT_EXP_WORD\n#define RECP_MUL_MOD\n#ifdef MONT_MUL_MOD\n    if (BN_is_odd(m)) {\n# ifdef MONT_EXP_WORD\n        if (a->top == 1 && !a->neg\n            && (BN_get_flags(p, BN_FLG_CONSTTIME) == 0)) {\n            BN_ULONG A = a->d[0];\n            ret = BN_mod_exp_mont_word(r, A, p, m, ctx, NULL);\n        } else\n# endif\n            ret = BN_mod_exp_mont(r, a, p, m, ctx, NULL);\n    } else\n#endif\n#ifdef RECP_MUL_MOD\n    {\n        ret = BN_mod_exp_recp(r, a, p, m, ctx);\n    }\n#else\n    {\n        ret = BN_mod_exp_simple(r, a, p, m, ctx);\n    }\n#endif\n    bn_check_top(r);\n    return (ret);\n}', 'int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx)\n{\n    int i, j, bits, ret = 0, wstart, wend, window, wvalue;\n    int start = 1;\n    BIGNUM *aa;\n    BIGNUM *val[TABLE_SIZE];\n    BN_RECP_CTX recp;\n    if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) {\n        BNerr(BN_F_BN_MOD_EXP_RECP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    bits = BN_num_bits(p);\n    if (bits == 0) {\n        if (BN_is_one(m)) {\n            ret = 1;\n            BN_zero(r);\n        } else {\n            ret = BN_one(r);\n        }\n        return ret;\n    }\n    BN_CTX_start(ctx);\n    aa = BN_CTX_get(ctx);\n    val[0] = BN_CTX_get(ctx);\n    if (val[0] == NULL)\n        goto err;\n    BN_RECP_CTX_init(&recp);\n    if (m->neg) {\n        if (!BN_copy(aa, m))\n            goto err;\n        aa->neg = 0;\n        if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0)\n            goto err;\n    } else {\n        if (BN_RECP_CTX_set(&recp, m, ctx) <= 0)\n            goto err;\n    }\n    if (!BN_nnmod(val[0], a, m, ctx))\n        goto err;\n    if (BN_is_zero(val[0])) {\n        BN_zero(r);\n        ret = 1;\n        goto err;\n    }\n    window = BN_window_bits_for_exponent_size(bits);\n    if (window > 1) {\n        if (!BN_mod_mul_reciprocal(aa, val[0], val[0], &recp, ctx))\n            goto err;\n        j = 1 << (window - 1);\n        for (i = 1; i < j; i++) {\n            if (((val[i] = BN_CTX_get(ctx)) == NULL) ||\n                !BN_mod_mul_reciprocal(val[i], val[i - 1], aa, &recp, ctx))\n                goto err;\n        }\n    }\n    start = 1;\n    wvalue = 0;\n    wstart = bits - 1;\n    wend = 0;\n    if (!BN_one(r))\n        goto err;\n    for (;;) {\n        if (BN_is_bit_set(p, wstart) == 0) {\n            if (!start)\n                if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx))\n                    goto err;\n            if (wstart == 0)\n                break;\n            wstart--;\n            continue;\n        }\n        j = wstart;\n        wvalue = 1;\n        wend = 0;\n        for (i = 1; i < window; i++) {\n            if (wstart - i < 0)\n                break;\n            if (BN_is_bit_set(p, wstart - i)) {\n                wvalue <<= (i - wend);\n                wvalue |= 1;\n                wend = i;\n            }\n        }\n        j = wend + 1;\n        if (!start)\n            for (i = 0; i < j; i++) {\n                if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx))\n                    goto err;\n            }\n        if (!BN_mod_mul_reciprocal(r, r, val[wvalue >> 1], &recp, ctx))\n            goto err;\n        wstart -= wend + 1;\n        wvalue = 0;\n        start = 0;\n        if (wstart < 0)\n            break;\n    }\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    BN_RECP_CTX_free(&recp);\n    bn_check_top(r);\n    return (ret);\n}', 'BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)\n{\n    bn_check_top(b);\n    if (a == b)\n        return a;\n    if (bn_wexpand(a, b->top) == NULL)\n        return NULL;\n    if (b->top > 0)\n        memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);\n    if (BN_get_flags(b, BN_FLG_CONSTTIME) != 0)\n        BN_set_flags(a, BN_FLG_CONSTTIME);\n    a->top = b->top;\n    a->neg = b->neg;\n    bn_check_top(a);\n    return a;\n}']