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


crypto/ec/ec2_smpl.c:445:14: Call
443.   
444.       if (a->Z_is_one) {
445.           if (!BN_copy(x0, a->X))
                    ^
446.               goto err;
447.           if (!BN_copy(y0, a->Y))

crypto/bn/bn_lib.c:280:1: Parameter `a->top`
  278.   }
  279.   
  280. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
  281.   {
  282.       bn_check_top(b);

crypto/ec/ec2_smpl.c:454:14: Call
452.       }
453.       if (b->Z_is_one) {
454.           if (!BN_copy(x1, b->X))
                    ^
455.               goto err;
456.           if (!BN_copy(y1, b->Y))

crypto/bn/bn_lib.c:280:1: Parameter `*a->d`
  278.   }
  279.   
  280. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
  281.   {
  282.       bn_check_top(b);

crypto/bn/bn_lib.c:286:9: Call
  284.       if (a == b)
  285.           return a;
  286.       if (bn_wexpand(a, b->top) == NULL)
                 ^
  287.           return NULL;
  288.   

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:944:37: Call
    942.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
    943.   {
    944.       return (words <= a->dmax) ? a : bn_expand2(a, words);
                                               ^
    945.   }
    946.   

crypto/bn/bn_lib.c:244:1: Parameter `*b->d`
      242.    */
      243.   
      244. > BIGNUM *bn_expand2(BIGNUM *b, int words)
      245.   {
      246.       if (words > b->dmax) {

crypto/bn/bn_lib.c:247:23: Call
      245.   {
      246.       if (words > b->dmax) {
      247.           BN_ULONG *a = bn_expand_internal(b, words);
                                   ^
      248.           if (!a)
      249.               return NULL;

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

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

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

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

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

static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
    BN_ULONG *a = NULL;
    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;
}
['int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                       const EC_POINT *b, BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *x0, *y0, *x1, *y1, *x2, *y2, *s, *t;\n    int ret = 0;\n    if (EC_POINT_is_at_infinity(group, a)) {\n        if (!EC_POINT_copy(r, b))\n            return 0;\n        return 1;\n    }\n    if (EC_POINT_is_at_infinity(group, b)) {\n        if (!EC_POINT_copy(r, a))\n            return 0;\n        return 1;\n    }\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n    BN_CTX_start(ctx);\n    x0 = BN_CTX_get(ctx);\n    y0 = BN_CTX_get(ctx);\n    x1 = BN_CTX_get(ctx);\n    y1 = BN_CTX_get(ctx);\n    x2 = BN_CTX_get(ctx);\n    y2 = BN_CTX_get(ctx);\n    s = BN_CTX_get(ctx);\n    t = BN_CTX_get(ctx);\n    if (t == NULL)\n        goto err;\n    if (a->Z_is_one) {\n        if (!BN_copy(x0, a->X))\n            goto err;\n        if (!BN_copy(y0, a->Y))\n            goto err;\n    } else {\n        if (!EC_POINT_get_affine_coordinates_GF2m(group, a, x0, y0, ctx))\n            goto err;\n    }\n    if (b->Z_is_one) {\n        if (!BN_copy(x1, b->X))\n            goto err;\n        if (!BN_copy(y1, b->Y))\n            goto err;\n    } else {\n        if (!EC_POINT_get_affine_coordinates_GF2m(group, b, x1, y1, ctx))\n            goto err;\n    }\n    if (BN_GF2m_cmp(x0, x1)) {\n        if (!BN_GF2m_add(t, x0, x1))\n            goto err;\n        if (!BN_GF2m_add(s, y0, y1))\n            goto err;\n        if (!group->meth->field_div(group, s, s, t, ctx))\n            goto err;\n        if (!group->meth->field_sqr(group, x2, s, ctx))\n            goto err;\n        if (!BN_GF2m_add(x2, x2, group->a))\n            goto err;\n        if (!BN_GF2m_add(x2, x2, s))\n            goto err;\n        if (!BN_GF2m_add(x2, x2, t))\n            goto err;\n    } else {\n        if (BN_GF2m_cmp(y0, y1) || BN_is_zero(x1)) {\n            if (!EC_POINT_set_to_infinity(group, r))\n                goto err;\n            ret = 1;\n            goto err;\n        }\n        if (!group->meth->field_div(group, s, y1, x1, ctx))\n            goto err;\n        if (!BN_GF2m_add(s, s, x1))\n            goto err;\n        if (!group->meth->field_sqr(group, x2, s, ctx))\n            goto err;\n        if (!BN_GF2m_add(x2, x2, s))\n            goto err;\n        if (!BN_GF2m_add(x2, x2, group->a))\n            goto err;\n    }\n    if (!BN_GF2m_add(y2, x1, x2))\n        goto err;\n    if (!group->meth->field_mul(group, y2, y2, s, ctx))\n        goto err;\n    if (!BN_GF2m_add(y2, y2, x2))\n        goto err;\n    if (!BN_GF2m_add(y2, y2, y1))\n        goto err;\n    if (!EC_POINT_set_affine_coordinates_GF2m(group, r, x2, y2, ctx))\n        goto err;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\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    a->neg = b->neg;\n    a->top = b->top;\n    a->flags |= b->flags & BN_FLG_FIXED_TOP;\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    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    return b;\n}', 'static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)\n{\n    BN_ULONG *a = NULL;\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}']