crypto/ec/ec_key.c:168: error: BUFFER_OVERRUN_L3
  Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, 8388607] by call to `BN_copy`.
Showing all 12 steps of the trace


crypto/ec/ec_key.c:124:1: Parameter `dest->priv_key->d`
122.   }
123.   
124. > EC_KEY *EC_KEY_copy(EC_KEY *dest, EC_KEY *src)
125.   {
126.       if (dest == NULL || src == NULL) {

crypto/ec/ec_key.c:168:18: Call
166.                       return NULL;
167.               }
168.               if (!BN_copy(dest->priv_key, src->priv_key))
                        ^
169.                   return NULL;
170.               if (src->group->meth->keycopy

crypto/bn/bn_lib.c:410:1: Parameter `*a->d`
  408.   }
  409.   
  410. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
  411.   {
  412.       int i;

crypto/bn/bn_lib.c:420:9: Call
  418.       if (a == b)
  419.           return (a);
  420.       if (bn_wexpand(a, b->top) == NULL)
                 ^
  421.           return (NULL);
  422.   

crypto/bn/bn_lib.c:1062:1: Parameter `*a->d`
    1060.   }
    1061.   
    1062. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1063.   {
    1064.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:1064:37: Call
    1062.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1063.   {
    1064.       return (words <= a->dmax) ? a : bn_expand2(a, words);
                                                ^
    1065.   }
    1066.   

crypto/bn/bn_lib.c:371:1: Parameter `*b->d`
      369.    */
      370.   
      371. > BIGNUM *bn_expand2(BIGNUM *b, int words)
      372.   {
      373.       bn_check_top(b);

crypto/bn/bn_lib.c:376:23: Call
      374.   
      375.       if (words > b->dmax) {
      376.           BN_ULONG *a = bn_expand_internal(b, words);
                                   ^
      377.           if (!a)
      378.               return NULL;

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

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

crypto/bn/bn_lib.c:320:5: Assignment
        318.   
        319.   #if 1
        320.       B = b->d;
                   ^
        321.       /* Check if the previous number needs to be copied */
        322.       if (B != NULL) {

crypto/bn/bn_lib.c:337:18: Array access: Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, 8388607] by call to `BN_copy` 
        335.               a1 = B[1];
        336.               a2 = B[2];
        337.               a3 = B[3];
                                ^
        338.               A[0] = a0;
        339.               A[1] = a1;

static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
    BN_ULONG *A, *a = NULL;
    const BN_ULONG *B;
    int i;
    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 = A = OPENSSL_secure_zalloc(words * sizeof(*a));
    else
        a = A = OPENSSL_zalloc(words * sizeof(*a));
    if (A == NULL) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
        return (NULL);
    }
#if 1
    B = b->d;
    if (B != NULL) {
        for (i = b->top >> 2; i > 0; i--, A += 4, B += 4) {
            BN_ULONG a0, a1, a2, a3;
            a0 = B[0];
            a1 = B[1];
            a2 = B[2];
            a3 = B[3];
            A[0] = a0;
            A[1] = a1;
            A[2] = a2;
            A[3] = a3;
        }
        switch (b->top & 3) {
        case 3:
            A[2] = B[2];
        case 2:
            A[1] = B[1];
        case 1:
            A[0] = B[0];
        case 0:
            ;
        }
    }
#else
    memset(A, 0, sizeof(*A) * words);
    memcpy(A, b->d, sizeof(b->d[0]) * b->top);
#endif
    return (a);
}
['EC_KEY *EC_KEY_copy(EC_KEY *dest, 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    int i;\n    BN_ULONG *A;\n    const BN_ULONG *B;\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 1\n    A = a->d;\n    B = b->d;\n    for (i = b->top >> 2; i > 0; i--, A += 4, B += 4) {\n        BN_ULONG a0, a1, a2, a3;\n        a0 = B[0];\n        a1 = B[1];\n        a2 = B[2];\n        a3 = B[3];\n        A[0] = a0;\n        A[1] = a1;\n        A[2] = a2;\n        A[3] = a3;\n    }\n    switch (b->top & 3) {\n    case 3:\n        A[2] = B[2];\n    case 2:\n        A[1] = B[1];\n    case 1:\n        A[0] = B[0];\n    case 0:;\n    }\n#else\n    memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);\n#endif\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, *a = NULL;\n    const BN_ULONG *B;\n    int i;\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 = A = OPENSSL_secure_zalloc(words * sizeof(*a));\n    else\n        a = 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#if 1\n    B = b->d;\n    if (B != NULL) {\n        for (i = b->top >> 2; i > 0; i--, A += 4, B += 4) {\n            BN_ULONG a0, a1, a2, a3;\n            a0 = B[0];\n            a1 = B[1];\n            a2 = B[2];\n            a3 = B[3];\n            A[0] = a0;\n            A[1] = a1;\n            A[2] = a2;\n            A[3] = a3;\n        }\n        switch (b->top & 3) {\n        case 3:\n            A[2] = B[2];\n        case 2:\n            A[1] = B[1];\n        case 1:\n            A[0] = B[0];\n        case 0:\n            ;\n        }\n    }\n#else\n    memset(A, 0, sizeof(*A) * words);\n    memcpy(A, b->d, sizeof(b->d[0]) * b->top);\n#endif\n    return (a);\n}']