crypto/ec/ec_ameth.c:356: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `EC_KEY_key2buf`.
Showing all 14 steps of the trace


crypto/ec/ec_ameth.c:356:18: Call
354.   
355.       if (ktype != EC_KEY_PRINT_PARAM && EC_KEY_get0_public_key(x) != NULL) {
356.           publen = EC_KEY_key2buf(x, EC_KEY_get_conv_form(x), &pub, NULL);
                        ^
357.           if (publen == 0)
358.               goto err;

crypto/ec/ec_key.c:617:1: Parameter `ctx->stack.depth`
  615.   }
  616.   
  617. > size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form,
  618.                           unsigned char **pbuf, BN_CTX *ctx)
  619.   {

crypto/ec/ec_key.c:622:12: Call
  620.       if (key == NULL || key->pub_key == NULL || key->group == NULL)
  621.           return 0;
  622.       return EC_POINT_point2buf(key->group, key->pub_key, form, pbuf, ctx);
                    ^
  623.   }
  624.   

crypto/ec/ec_oct.c:129:1: Parameter `ctx->stack.depth`
    127.   }
    128.   
    129. > size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,
    130.                             point_conversion_form_t form,
    131.                             unsigned char **pbuf, BN_CTX *ctx)

crypto/ec/ec_oct.c:143:11: Call
    141.           return 0;
    142.       }
    143.       len = EC_POINT_point2oct(group, point, form, buf, len, ctx);
                     ^
    144.       if (len == 0) {
    145.           OPENSSL_free(buf);

crypto/ec/ec_oct.c:70:1: Parameter `ctx->stack.depth`
      68.   #endif
      69.   
      70. > size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
      71.                             point_conversion_form_t form, unsigned char *buf,
      72.                             size_t len, BN_CTX *ctx)

crypto/ec/ec_oct.c:93:20: Call
      91.           }
      92.   #else
      93.               return ec_GF2m_simple_point2oct(group, point,
                               ^
      94.                                               form, buf, len, ctx);
      95.   #endif

crypto/ec/ec2_oct.c:121:1: Parameter `ctx->stack.depth`
        119.    * an error will be returned.
        120.    */
        121. > size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
        122.                                   point_conversion_form_t form,
        123.                                   unsigned char *buf, size_t len, BN_CTX *ctx)

crypto/ec/ec2_oct.c:232:9: Call
        230.   
        231.       if (used_ctx)
        232.           BN_CTX_end(ctx);
                       ^
        233.   #ifndef FIPS_MODE
        234.       BN_CTX_free(new_ctx);

crypto/bn/bn_ctx.c:208:1: Parameter `ctx->stack.depth`
          206.   }
          207.   
          208. > void BN_CTX_end(BN_CTX *ctx)
          209.   {
          210.       if (ctx == NULL)

crypto/bn/bn_ctx.c:216:27: Call
          214.           ctx->err_stack--;
          215.       else {
          216.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                           ^
          217.           /* Does this stack frame have anything to release? */
          218.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:298:1: <LHS trace>
296.   }
297.   
298. > static unsigned int BN_STACK_pop(BN_STACK *st)
299.   {
300.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:298:1: Parameter `st->depth`
            296.   }
            297.   
            298. > static unsigned int BN_STACK_pop(BN_STACK *st)
            299.   {
            300.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:300:12: Binary operation: ([0, +oo] - 1):unsigned32 by call to `EC_KEY_key2buf` 
            298.   static unsigned int BN_STACK_pop(BN_STACK *st)
            299.   {
            300.       return st->indexes[--(st->depth)];
                              ^
            301.   }
            302.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, ec_print_t ktype)\n{\n    const char *ecstr;\n    unsigned char *priv = NULL, *pub = NULL;\n    size_t privlen = 0, publen = 0;\n    int ret = 0;\n    const EC_GROUP *group;\n    if (x == NULL || (group = EC_KEY_get0_group(x)) == NULL) {\n        ECerr(EC_F_DO_EC_KEY_PRINT, ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n    if (ktype != EC_KEY_PRINT_PARAM && EC_KEY_get0_public_key(x) != NULL) {\n        publen = EC_KEY_key2buf(x, EC_KEY_get_conv_form(x), &pub, NULL);\n        if (publen == 0)\n            goto err;\n    }\n    if (ktype == EC_KEY_PRINT_PRIVATE && EC_KEY_get0_private_key(x) != NULL) {\n        privlen = EC_KEY_priv2buf(x, &priv);\n        if (privlen == 0)\n            goto err;\n    }\n    if (ktype == EC_KEY_PRINT_PRIVATE)\n        ecstr = "Private-Key";\n    else if (ktype == EC_KEY_PRINT_PUBLIC)\n        ecstr = "Public-Key";\n    else\n        ecstr = "ECDSA-Parameters";\n    if (!BIO_indent(bp, off, 128))\n        goto err;\n    if (BIO_printf(bp, "%s: (%d bit)\\n", ecstr,\n                   EC_GROUP_order_bits(group)) <= 0)\n        goto err;\n    if (privlen != 0) {\n        if (BIO_printf(bp, "%*spriv:\\n", off, "") <= 0)\n            goto err;\n        if (ASN1_buf_print(bp, priv, privlen, off + 4) == 0)\n            goto err;\n    }\n    if (publen != 0) {\n        if (BIO_printf(bp, "%*spub:\\n", off, "") <= 0)\n            goto err;\n        if (ASN1_buf_print(bp, pub, publen, off + 4) == 0)\n            goto err;\n    }\n    if (!ECPKParameters_print(bp, group, off))\n        goto err;\n    ret = 1;\n err:\n    if (!ret)\n        ECerr(EC_F_DO_EC_KEY_PRINT, ERR_R_EC_LIB);\n    OPENSSL_clear_free(priv, privlen);\n    OPENSSL_free(pub);\n    return ret;\n}', 'size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form,\n                        unsigned char **pbuf, BN_CTX *ctx)\n{\n    if (key == NULL || key->pub_key == NULL || key->group == NULL)\n        return 0;\n    return EC_POINT_point2buf(key->group, key->pub_key, form, pbuf, ctx);\n}', 'size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,\n                          point_conversion_form_t form,\n                          unsigned char **pbuf, BN_CTX *ctx)\n{\n    size_t len;\n    unsigned char *buf;\n    len = EC_POINT_point2oct(group, point, form, NULL, 0, NULL);\n    if (len == 0)\n        return 0;\n    if ((buf = OPENSSL_malloc(len)) == NULL) {\n        ECerr(EC_F_EC_POINT_POINT2BUF, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    len = EC_POINT_point2oct(group, point, form, buf, len, ctx);\n    if (len == 0) {\n        OPENSSL_free(buf);\n        return 0;\n    }\n    *pbuf = buf;\n    return len;\n}', 'size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,\n                          point_conversion_form_t form, unsigned char *buf,\n                          size_t len, BN_CTX *ctx)\n{\n    if (group->meth->point2oct == 0\n        && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {\n        ECerr(EC_F_EC_POINT_POINT2OCT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(point, group)) {\n        ECerr(EC_F_EC_POINT_POINT2OCT, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {\n        if (group->meth->field_type == NID_X9_62_prime_field)\n            return ec_GFp_simple_point2oct(group, point, form, buf, len, ctx);\n        else\n#ifdef OPENSSL_NO_EC2M\n        {\n            ECerr(EC_F_EC_POINT_POINT2OCT, EC_R_GF2M_NOT_SUPPORTED);\n            return 0;\n        }\n#else\n            return ec_GF2m_simple_point2oct(group, point,\n                                            form, buf, len, ctx);\n#endif\n    }\n    return group->meth->point2oct(group, point, form, buf, len, ctx);\n}', 'size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,\n                                point_conversion_form_t form,\n                                unsigned char *buf, size_t len, BN_CTX *ctx)\n{\n    size_t ret;\n    int used_ctx = 0;\n    BIGNUM *x, *y, *yxi;\n    size_t field_len, i, skip;\n#ifndef FIPS_MODE\n    BN_CTX *new_ctx = NULL;\n#endif\n    if ((form != POINT_CONVERSION_COMPRESSED)\n        && (form != POINT_CONVERSION_UNCOMPRESSED)\n        && (form != POINT_CONVERSION_HYBRID)) {\n        ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_INVALID_FORM);\n        goto err;\n    }\n    if (EC_POINT_is_at_infinity(group, point)) {\n        if (buf != NULL) {\n            if (len < 1) {\n                ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL);\n                return 0;\n            }\n            buf[0] = 0;\n        }\n        return 1;\n    }\n    field_len = (EC_GROUP_get_degree(group) + 7) / 8;\n    ret =\n        (form ==\n         POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len;\n    if (buf != NULL) {\n        if (len < ret) {\n            ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL);\n            goto err;\n        }\n#ifndef FIPS_MODE\n        if (ctx == NULL) {\n            ctx = new_ctx = BN_CTX_new();\n            if (ctx == NULL)\n                return 0;\n        }\n#endif\n        BN_CTX_start(ctx);\n        used_ctx = 1;\n        x = BN_CTX_get(ctx);\n        y = BN_CTX_get(ctx);\n        yxi = BN_CTX_get(ctx);\n        if (yxi == NULL)\n            goto err;\n        if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))\n            goto err;\n        buf[0] = form;\n        if ((form != POINT_CONVERSION_UNCOMPRESSED) && !BN_is_zero(x)) {\n            if (!group->meth->field_div(group, yxi, y, x, ctx))\n                goto err;\n            if (BN_is_odd(yxi))\n                buf[0]++;\n        }\n        i = 1;\n        skip = field_len - BN_num_bytes(x);\n        if (skip > field_len) {\n            ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n        while (skip > 0) {\n            buf[i++] = 0;\n            skip--;\n        }\n        skip = BN_bn2bin(x, buf + i);\n        i += skip;\n        if (i != 1 + field_len) {\n            ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n        if (form == POINT_CONVERSION_UNCOMPRESSED\n            || form == POINT_CONVERSION_HYBRID) {\n            skip = field_len - BN_num_bytes(y);\n            if (skip > field_len) {\n                ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n            while (skip > 0) {\n                buf[i++] = 0;\n                skip--;\n            }\n            skip = BN_bn2bin(y, buf + i);\n            i += skip;\n        }\n        if (i != ret) {\n            ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n    }\n    if (used_ctx)\n        BN_CTX_end(ctx);\n#ifndef FIPS_MODE\n    BN_CTX_free(new_ctx);\n#endif\n    return ret;\n err:\n    if (used_ctx)\n        BN_CTX_end(ctx);\n#ifndef FIPS_MODE\n    BN_CTX_free(new_ctx);\n#endif\n    return 0;\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    CTXDBG("ENTER BN_CTX_end()", ctx);\n    if (ctx->err_stack)\n        ctx->err_stack--;\n    else {\n        unsigned int fp = BN_STACK_pop(&ctx->stack);\n        if (fp < ctx->used)\n            BN_POOL_release(&ctx->pool, ctx->used - fp);\n        ctx->used = fp;\n        ctx->too_many = 0;\n    }\n    CTXDBG("LEAVE BN_CTX_end()", ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']