crypto/ec/ec_key.c:121: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_copy`.
Showing all 13 steps of the trace


crypto/ec/ec_key.c:77:1: Parameter `dest->priv_key->d`
75.   }
76.   
77. > EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
78.   {
79.       if (dest == NULL || src == NULL) {

crypto/ec/ec_key.c:121:18: Call
119.                       return NULL;
120.               }
121.               if (!BN_copy(dest->priv_key, src->priv_key))
                        ^
122.                   return NULL;
123.               if (src->group->meth->keycopy

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

crypto/bn/bn_lib.c:329:9: Call
  327.       if (a == b)
  328.           return a;
  329.       if (bn_wexpand(a, b->top) == NULL)
                 ^
  330.           return NULL;
  331.   

crypto/bn/bn_lib.c:948:1: Parameter `*a->d`
    946.   }
    947.   
    948. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
    949.   {
    950.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:950:37: Call
    948.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
    949.   {
    950.       return (words <= a->dmax) ? a : bn_expand2(a, words);
                                               ^
    951.   }
    952.   

crypto/bn/bn_lib.c:284:1: Parameter `*b->d`
      282.    */
      283.   
      284. > BIGNUM *bn_expand2(BIGNUM *b, int words)
      285.   {
      286.       bn_check_top(b);

crypto/bn/bn_lib.c:289:23: Call
      287.   
      288.       if (words > b->dmax) {
      289.           BN_ULONG *a = bn_expand_internal(b, words);
                                   ^
      290.           if (!a)
      291.               return NULL;

crypto/bn/bn_lib.c:246:1: <Offset trace>
244.   /* This is used by bn_expand2() */
245.   /* The caller MUST check that words > b->dmax before calling this */
246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
247.   {
248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:246:1: Parameter `b->top`
        244.   /* This is used by bn_expand2() */
        245.   /* The caller MUST check that words > b->dmax before calling this */
        246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
        247.   {
        248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:246:1: <Length trace>
244.   /* This is used by bn_expand2() */
245.   /* The caller MUST check that words > b->dmax before calling this */
246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
247.   {
248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:246:1: Parameter `*b->d`
        244.   /* This is used by bn_expand2() */
        245.   /* The caller MUST check that words > b->dmax before calling this */
        246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
        247.   {
        248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:271:9: Array access: Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_copy` 
        269.       assert(b->top <= words);
        270.       if (b->top > 0)
        271.           memcpy(a, b->d, sizeof(*a) * b->top);
                       ^
        272.   
        273.       return a;

static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
    BN_ULONG *a = NULL;
    bn_check_top(b);
    if (words > (INT_MAX / (4 * BN_BITS2))) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);
        return NULL;
    }
    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
        return (NULL);
    }
    if (BN_get_flags(b, BN_FLG_SECURE))
        a = OPENSSL_secure_zalloc(words * sizeof(*a));
    else
        a = OPENSSL_zalloc(words * sizeof(*a));
    if (a == NULL) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
        return (NULL);
    }
    assert(b->top <= words);
    if (b->top > 0)
        memcpy(a, b->d, sizeof(*a) * b->top);
    return a;
}
['EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)\n{\n    if (dest == NULL || src == NULL) {\n        ECerr(EC_F_EC_KEY_COPY, ERR_R_PASSED_NULL_PARAMETER);\n        return NULL;\n    }\n    if (src->meth != dest->meth) {\n        if (dest->meth->finish != NULL)\n            dest->meth->finish(dest);\n        if (dest->group && dest->group->meth->keyfinish)\n            dest->group->meth->keyfinish(dest);\n#ifndef OPENSSL_NO_ENGINE\n        if (ENGINE_finish(dest->engine) == 0)\n            return 0;\n        dest->engine = NULL;\n#endif\n    }\n    if (src->group != NULL) {\n        const EC_METHOD *meth = EC_GROUP_method_of(src->group);\n        EC_GROUP_free(dest->group);\n        dest->group = EC_GROUP_new(meth);\n        if (dest->group == NULL)\n            return NULL;\n        if (!EC_GROUP_copy(dest->group, src->group))\n            return NULL;\n        if (src->pub_key != NULL) {\n            EC_POINT_free(dest->pub_key);\n            dest->pub_key = EC_POINT_new(src->group);\n            if (dest->pub_key == NULL)\n                return NULL;\n            if (!EC_POINT_copy(dest->pub_key, src->pub_key))\n                return NULL;\n        }\n        if (src->priv_key != NULL) {\n            if (dest->priv_key == NULL) {\n                dest->priv_key = BN_new();\n                if (dest->priv_key == NULL)\n                    return NULL;\n            }\n            if (!BN_copy(dest->priv_key, src->priv_key))\n                return NULL;\n            if (src->group->meth->keycopy\n                && src->group->meth->keycopy(dest, src) == 0)\n                return NULL;\n        }\n    }\n    dest->enc_flag = src->enc_flag;\n    dest->conv_form = src->conv_form;\n    dest->version = src->version;\n    dest->flags = src->flags;\n    if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_EC_KEY,\n                            &dest->ex_data, &src->ex_data))\n        return NULL;\n    if (src->meth != dest->meth) {\n#ifndef OPENSSL_NO_ENGINE\n        if (src->engine != NULL && ENGINE_init(src->engine) == 0)\n            return NULL;\n        dest->engine = src->engine;\n#endif\n        dest->meth = src->meth;\n    }\n    if (src->meth->copy != NULL && src->meth->copy(dest, src) == 0)\n        return NULL;\n    return dest;\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    a->top = b->top;\n    a->neg = b->neg;\n    bn_check_top(a);\n    return a;\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}', 'BIGNUM *bn_expand2(BIGNUM *b, int words)\n{\n    bn_check_top(b);\n    if (words > b->dmax) {\n        BN_ULONG *a = bn_expand_internal(b, words);\n        if (!a)\n            return NULL;\n        if (b->d) {\n            OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0]));\n            bn_free_d(b);\n        }\n        b->d = a;\n        b->dmax = words;\n    }\n    bn_check_top(b);\n    return b;\n}', 'static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)\n{\n    BN_ULONG *a = NULL;\n    bn_check_top(b);\n    if (words > (INT_MAX / (4 * BN_BITS2))) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);\n        return NULL;\n    }\n    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);\n        return (NULL);\n    }\n    if (BN_get_flags(b, BN_FLG_SECURE))\n        a = OPENSSL_secure_zalloc(words * sizeof(*a));\n    else\n        a = OPENSSL_zalloc(words * sizeof(*a));\n    if (a == NULL) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    assert(b->top <= words);\n    if (b->top > 0)\n        memcpy(a, b->d, sizeof(*a) * b->top);\n    return a;\n}']