crypto/ec/ec_asn1.c:869: error: BUFFER_OVERRUN_L2
  Offset: [-oo, 9223372036854775807] Size: [0, 8388607] by call to `EC_GROUP_new_from_ecpkparameters`.
Showing all 12 steps of the trace


crypto/ec/ec_asn1.c:869:18: Call
867.       }
868.   
869.       if ((group = EC_GROUP_new_from_ecpkparameters(params)) == NULL) {
                        ^
870.           ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_PKPARAMETERS2GROUP_FAILURE);
871.           ECPKPARAMETERS_free(params);

crypto/ec/ec_asn1.c:819:1: Parameter `params->value.parameters->fieldID->p.char_two->m`
  817.   }
  818.   
  819. > EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params)
  820.   {
  821.       EC_GROUP *ret = NULL;

crypto/ec/ec_asn1.c:839:15: Call
  837.       } else if (params->type == 1) { /* the parameters are given by a
  838.                                        * ECPARAMETERS structure */
  839.           ret = EC_GROUP_new_from_ecparameters(params->value.parameters);
                       ^
  840.           if (!ret) {
  841.               ECerr(EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS, ERR_R_EC_LIB);

crypto/ec/ec_asn1.c:580:1: Parameter `params->fieldID->p.char_two->m`
    578.   }
    579.   
    580. > EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params)
    581.   {
    582.       int ok = 0, tmp;

crypto/ec/ec_asn1.c:664:18: Call
    662.               if (!BN_set_bit(p, (int)char_two->m))
    663.                   goto err;
    664.               if (!BN_set_bit(p, (int)tmp_long))
                            ^
    665.                   goto err;
    666.               if (!BN_set_bit(p, 0))

crypto/bn/bn_lib.c:588:1: <Offset trace>
586.   }
587.   
588. > int BN_set_bit(BIGNUM *a, int n)
589.   {
590.       int i, j, k;

crypto/bn/bn_lib.c:588:1: Parameter `a->top`
      586.   }
      587.   
      588. > int BN_set_bit(BIGNUM *a, int n)
      589.   {
      590.       int i, j, k;

crypto/bn/bn_lib.c:588:1: <Length trace>
586.   }
587.   
588. > int BN_set_bit(BIGNUM *a, int n)
589.   {
590.       int i, j, k;

crypto/bn/bn_lib.c:588:1: Parameter `*a->d`
      586.   }
      587.   
      588. > int BN_set_bit(BIGNUM *a, int n)
      589.   {
      590.       int i, j, k;

crypto/bn/bn_lib.c:598:13: Call
      596.       j = n % BN_BITS2;
      597.       if (a->top <= i) {
      598.           if (bn_wexpand(a, i + 1) == NULL)
                         ^
      599.               return 0;
      600.           for (k = a->top; k < i + 1; k++)

crypto/bn/bn_lib.c:942:1: Parameter `*a->d`
        940.   }
        941.   
        942. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
        943.   {
        944.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:601:13: Array access: Offset: [-oo, 9223372036854775807] Size: [0, 8388607] by call to `EC_GROUP_new_from_ecpkparameters` 
      599.               return 0;
      600.           for (k = a->top; k < i + 1; k++)
      601.               a->d[k] = 0;
                         ^
      602.           a->top = i + 1;
      603.           a->flags &= ~BN_FLG_FIXED_TOP;

int BN_set_bit(BIGNUM *a, int n)
{
    int i, j, k;
    if (n < 0)
        return 0;
    i = n / BN_BITS2;
    j = n % BN_BITS2;
    if (a->top <= i) {
        if (bn_wexpand(a, i + 1) == NULL)
            return 0;
        for (k = a->top; k < i + 1; k++)
            a->d[k] = 0;
        a->top = i + 1;
        a->flags &= ~BN_FLG_FIXED_TOP;
    }
    a->d[i] |= (((BN_ULONG)1) << j);
    bn_check_top(a);
    return 1;
}
['EC_GROUP *d2i_ECPKParameters(EC_GROUP **a, const unsigned char **in, long len)\n{\n    EC_GROUP *group = NULL;\n    ECPKPARAMETERS *params = NULL;\n    const unsigned char *p = *in;\n    if ((params = d2i_ECPKPARAMETERS(NULL, &p, len)) == NULL) {\n        ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_D2I_ECPKPARAMETERS_FAILURE);\n        ECPKPARAMETERS_free(params);\n        return NULL;\n    }\n    if ((group = EC_GROUP_new_from_ecpkparameters(params)) == NULL) {\n        ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_PKPARAMETERS2GROUP_FAILURE);\n        ECPKPARAMETERS_free(params);\n        return NULL;\n    }\n    if (a) {\n        EC_GROUP_clear_free(*a);\n        *a = group;\n    }\n    ECPKPARAMETERS_free(params);\n    *in = p;\n    return group;\n}', 'EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params)\n{\n    EC_GROUP *ret = NULL;\n    int tmp = 0;\n    if (params == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS, EC_R_MISSING_PARAMETERS);\n        return NULL;\n    }\n    if (params->type == 0) {\n        tmp = OBJ_obj2nid(params->value.named_curve);\n        if ((ret = EC_GROUP_new_by_curve_name(tmp)) == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS,\n                  EC_R_EC_GROUP_NEW_BY_NAME_FAILURE);\n            return NULL;\n        }\n        EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_NAMED_CURVE);\n    } else if (params->type == 1) {\n        ret = EC_GROUP_new_from_ecparameters(params->value.parameters);\n        if (!ret) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS, ERR_R_EC_LIB);\n            return NULL;\n        }\n        EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_EXPLICIT_CURVE);\n    } else if (params->type == 2) {\n        return NULL;\n    } else {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS, EC_R_ASN1_ERROR);\n        return NULL;\n    }\n    return ret;\n}', 'EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params)\n{\n    int ok = 0, tmp;\n    EC_GROUP *ret = NULL;\n    BIGNUM *p = NULL, *a = NULL, *b = NULL;\n    EC_POINT *point = NULL;\n    long field_bits;\n    if (!params->fieldID || !params->fieldID->fieldType ||\n        !params->fieldID->p.ptr) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n        goto err;\n    }\n    if (!params->curve || !params->curve->a ||\n        !params->curve->a->data || !params->curve->b ||\n        !params->curve->b->data) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n        goto err;\n    }\n    a = BN_bin2bn(params->curve->a->data, params->curve->a->length, NULL);\n    if (a == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB);\n        goto err;\n    }\n    b = BN_bin2bn(params->curve->b->data, params->curve->b->length, NULL);\n    if (b == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB);\n        goto err;\n    }\n    tmp = OBJ_obj2nid(params->fieldID->fieldType);\n    if (tmp == NID_X9_62_characteristic_two_field)\n#ifdef OPENSSL_NO_EC2M\n    {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_GF2M_NOT_SUPPORTED);\n        goto err;\n    }\n#else\n    {\n        X9_62_CHARACTERISTIC_TWO *char_two;\n        char_two = params->fieldID->p.char_two;\n        field_bits = char_two->m;\n        if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_FIELD_TOO_LARGE);\n            goto err;\n        }\n        if ((p = BN_new()) == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        tmp = OBJ_obj2nid(char_two->type);\n        if (tmp == NID_X9_62_tpBasis) {\n            long tmp_long;\n            if (!char_two->p.tpBasis) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n                goto err;\n            }\n            tmp_long = ASN1_INTEGER_get(char_two->p.tpBasis);\n            if (!(char_two->m > tmp_long && tmp_long > 0)) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS,\n                      EC_R_INVALID_TRINOMIAL_BASIS);\n                goto err;\n            }\n            if (!BN_set_bit(p, (int)char_two->m))\n                goto err;\n            if (!BN_set_bit(p, (int)tmp_long))\n                goto err;\n            if (!BN_set_bit(p, 0))\n                goto err;\n        } else if (tmp == NID_X9_62_ppBasis) {\n            X9_62_PENTANOMIAL *penta;\n            penta = char_two->p.ppBasis;\n            if (!penta) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n                goto err;\n            }\n            if (!\n                (char_two->m > penta->k3 && penta->k3 > penta->k2\n                 && penta->k2 > penta->k1 && penta->k1 > 0)) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS,\n                      EC_R_INVALID_PENTANOMIAL_BASIS);\n                goto err;\n            }\n            if (!BN_set_bit(p, (int)char_two->m))\n                goto err;\n            if (!BN_set_bit(p, (int)penta->k1))\n                goto err;\n            if (!BN_set_bit(p, (int)penta->k2))\n                goto err;\n            if (!BN_set_bit(p, (int)penta->k3))\n                goto err;\n            if (!BN_set_bit(p, 0))\n                goto err;\n        } else if (tmp == NID_X9_62_onBasis) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_NOT_IMPLEMENTED);\n            goto err;\n        } else {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n            goto err;\n        }\n        ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL);\n    }\n#endif\n    else if (tmp == NID_X9_62_prime_field) {\n        if (!params->fieldID->p.prime) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n            goto err;\n        }\n        p = ASN1_INTEGER_to_BN(params->fieldID->p.prime, NULL);\n        if (p == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB);\n            goto err;\n        }\n        if (BN_is_negative(p) || BN_is_zero(p)) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_FIELD);\n            goto err;\n        }\n        field_bits = BN_num_bits(p);\n        if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_FIELD_TOO_LARGE);\n            goto err;\n        }\n        ret = EC_GROUP_new_curve_GFp(p, a, b, NULL);\n    } else {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_FIELD);\n        goto err;\n    }\n    if (ret == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    if (params->curve->seed != NULL) {\n        OPENSSL_free(ret->seed);\n        if ((ret->seed = OPENSSL_malloc(params->curve->seed->length)) == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        memcpy(ret->seed, params->curve->seed->data,\n               params->curve->seed->length);\n        ret->seed_len = params->curve->seed->length;\n    }\n    if (!params->order || !params->base || !params->base->data) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n        goto err;\n    }\n    if ((point = EC_POINT_new(ret)) == NULL)\n        goto err;\n    EC_GROUP_set_point_conversion_form(ret, (point_conversion_form_t)\n                                       (params->base->data[0] & ~0x01));\n    if (!EC_POINT_oct2point(ret, point, params->base->data,\n                            params->base->length, NULL)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    if ((a = ASN1_INTEGER_to_BN(params->order, a)) == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB);\n        goto err;\n    }\n    if (BN_is_negative(a) || BN_is_zero(a)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_GROUP_ORDER);\n        goto err;\n    }\n    if (BN_num_bits(a) > (int)field_bits + 1) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_GROUP_ORDER);\n        goto err;\n    }\n    if (params->cofactor == NULL) {\n        BN_free(b);\n        b = NULL;\n    } else if ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB);\n        goto err;\n    }\n    if (!EC_GROUP_set_generator(ret, point, a, b)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    ok = 1;\n err:\n    if (!ok) {\n        EC_GROUP_clear_free(ret);\n        ret = NULL;\n    }\n    BN_free(p);\n    BN_free(a);\n    BN_free(b);\n    EC_POINT_free(point);\n    return ret;\n}', 'int BN_set_bit(BIGNUM *a, int n)\n{\n    int i, j, k;\n    if (n < 0)\n        return 0;\n    i = n / BN_BITS2;\n    j = n % BN_BITS2;\n    if (a->top <= i) {\n        if (bn_wexpand(a, i + 1) == NULL)\n            return 0;\n        for (k = a->top; k < i + 1; k++)\n            a->d[k] = 0;\n        a->top = i + 1;\n        a->flags &= ~BN_FLG_FIXED_TOP;\n    }\n    a->d[i] |= (((BN_ULONG)1) << j);\n    bn_check_top(a);\n    return 1;\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}']