crypto/ec/ecp_smpl.c:1518: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_mod_lshift_quick`.
Showing all 18 steps of the trace


crypto/ec/ecp_smpl.c:1499:10: Call
1497.   
1498.       BN_CTX_start(ctx);
1499.       t0 = BN_CTX_get(ctx);
                 ^
1500.       t1 = BN_CTX_get(ctx);
1501.       t2 = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:229:5: Call
  227.       }
  228.       /* OK, make sure the returned bignum is "zero" */
  229.       BN_zero(ret);
             ^
  230.       ctx->used++;
  231.       CTXDBG_RET(ctx, ret);

crypto/bn/bn_lib.c:366:15: Assignment
    364.       a->neg = 0;
    365.       a->d[0] = w;
    366.       a->top = (w ? 1 : 0);
                         ^
    367.       a->flags &= ~BN_FLG_FIXED_TOP;
    368.       bn_check_top(a);

crypto/bn/bn_lib.c:366:5: Assignment
    364.       a->neg = 0;
    365.       a->d[0] = w;
    366.       a->top = (w ? 1 : 0);
               ^
    367.       a->flags &= ~BN_FLG_FIXED_TOP;
    368.       bn_check_top(a);

crypto/ec/ecp_smpl.c:1518:13: Call
1516.           || !group->meth->field_mul(group, t0, t4, t0, ctx)
1517.           || !group->meth->field_sqr(group, t1, t1, ctx)
1518.           || !BN_mod_lshift_quick(t7, group->b, 2, group->field)
                    ^
1519.           || !group->meth->field_mul(group, t1, t7, t1, ctx)
1520.           || !BN_mod_lshift1_quick(t0, t0, group->field)

crypto/bn/bn_mod.c:214:1: Parameter `*r->d`
  212.    * m
  213.    */
  214. > int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m)
  215.   {
  216.       if (r != a) {

crypto/bn/bn_mod.c:217:13: Call
  215.   {
  216.       if (r != a) {
  217.           if (BN_copy(r, a) == NULL)
                     ^
  218.               return 0;
  219.       }

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

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

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:245:1: Parameter `*b->d`
        243.    */
        244.   
        245. > BIGNUM *bn_expand2(BIGNUM *b, int words)
        246.   {
        247.       if (words > b->dmax) {

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

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

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

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

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

crypto/bn/bn_lib.c:232:9: Array access: Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_mod_lshift_quick` 
          230.       assert(b->top <= words);
          231.       if (b->top > 0)
          232.           memcpy(a, b->d, sizeof(*a) * b->top);
                         ^
          233.   
          234.       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_GFp_simple_ladder_step(const EC_GROUP *group,\n                              EC_POINT *r, EC_POINT *s,\n                              EC_POINT *p, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6, *t7 = NULL;\n    BN_CTX_start(ctx);\n    t0 = BN_CTX_get(ctx);\n    t1 = BN_CTX_get(ctx);\n    t2 = BN_CTX_get(ctx);\n    t3 = BN_CTX_get(ctx);\n    t4 = BN_CTX_get(ctx);\n    t5 = BN_CTX_get(ctx);\n    t6 = BN_CTX_get(ctx);\n    t7 = BN_CTX_get(ctx);\n    if (t7 == NULL\n        || !group->meth->field_mul(group, t0, r->X, s->X, ctx)\n        || !group->meth->field_mul(group, t1, r->Z, s->Z, ctx)\n        || !group->meth->field_mul(group, t2, r->X, s->Z, ctx)\n        || !group->meth->field_mul(group, t3, r->Z, s->X, ctx)\n        || !group->meth->field_mul(group, t4, group->a, t1, ctx)\n        || !BN_mod_add_quick(t0, t0, t4, group->field)\n        || !BN_mod_add_quick(t4, t3, t2, group->field)\n        || !group->meth->field_mul(group, t0, t4, t0, ctx)\n        || !group->meth->field_sqr(group, t1, t1, ctx)\n        || !BN_mod_lshift_quick(t7, group->b, 2, group->field)\n        || !group->meth->field_mul(group, t1, t7, t1, ctx)\n        || !BN_mod_lshift1_quick(t0, t0, group->field)\n        || !BN_mod_add_quick(t0, t1, t0, group->field)\n        || !BN_mod_sub_quick(t1, t2, t3, group->field)\n        || !group->meth->field_sqr(group, t1, t1, ctx)\n        || !group->meth->field_mul(group, t3, t1, p->X, ctx)\n        || !group->meth->field_mul(group, t0, p->Z, t0, ctx)\n        || !BN_mod_sub_quick(s->X, t0, t3, group->field)\n        || !group->meth->field_mul(group, s->Z, p->Z, t1, ctx)\n        || !group->meth->field_sqr(group, t3, r->X, ctx)\n        || !group->meth->field_sqr(group, t2, r->Z, ctx)\n        || !group->meth->field_mul(group, t4, t2, group->a, ctx)\n        || !BN_mod_add_quick(t5, r->X, r->Z, group->field)\n        || !group->meth->field_sqr(group, t5, t5, ctx)\n        || !BN_mod_sub_quick(t5, t5, t3, group->field)\n        || !BN_mod_sub_quick(t5, t5, t2, group->field)\n        || !BN_mod_sub_quick(t6, t3, t4, group->field)\n        || !group->meth->field_sqr(group, t6, t6, ctx)\n        || !group->meth->field_mul(group, t0, t2, t5, ctx)\n        || !group->meth->field_mul(group, t0, t7, t0, ctx)\n        || !BN_mod_sub_quick(r->X, t6, t0, group->field)\n        || !BN_mod_add_quick(t6, t3, t4, group->field)\n        || !group->meth->field_sqr(group, t3, t2, ctx)\n        || !group->meth->field_mul(group, t7, t3, t7, ctx)\n        || !group->meth->field_mul(group, t5, t5, t6, ctx)\n        || !BN_mod_lshift1_quick(t5, t5, group->field)\n        || !BN_mod_add_quick(r->Z, t7, t5, group->field))\n        goto err;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    return ret;\n}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n{\n    BIGNUM *ret;\n    CTXDBG_ENTRY("BN_CTX_get", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        return NULL;\n    if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {\n        ctx->too_many = 1;\n        BNerr(BN_F_BN_CTX_GET, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        return NULL;\n    }\n    BN_zero(ret);\n    ctx->used++;\n    CTXDBG_RET(ctx, ret);\n    return ret;\n}', 'int BN_set_word(BIGNUM *a, BN_ULONG w)\n{\n    bn_check_top(a);\n    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)\n        return 0;\n    a->neg = 0;\n    a->d[0] = w;\n    a->top = (w ? 1 : 0);\n    a->flags &= ~BN_FLG_FIXED_TOP;\n    bn_check_top(a);\n    return 1;\n}', 'int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m)\n{\n    if (r != a) {\n        if (BN_copy(r, a) == NULL)\n            return 0;\n    }\n    while (n > 0) {\n        int max_shift;\n        max_shift = BN_num_bits(m) - BN_num_bits(r);\n        if (max_shift < 0) {\n            BNerr(BN_F_BN_MOD_LSHIFT_QUICK, BN_R_INPUT_NOT_REDUCED);\n            return 0;\n        }\n        if (max_shift > n)\n            max_shift = n;\n        if (max_shift) {\n            if (!BN_lshift(r, r, max_shift))\n                return 0;\n            n -= max_shift;\n        } else {\n            if (!BN_lshift1(r, r))\n                return 0;\n            --n;\n        }\n        if (BN_cmp(r, m) >= 0) {\n            if (!BN_sub(r, r, m))\n                return 0;\n        }\n    }\n    bn_check_top(r);\n    return 1;\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}']