ssl/statem/statem_srvr.c:3034: error: BUFFER_OVERRUN_L3
  Offset added: [1, 65280] Size: [8, 522240] by call to `EVP_EncryptUpdate`.
Showing all 9 steps of the trace


ssl/statem/statem_srvr.c:2941:17: Call
2939.   
2940.       /* get session encoding length */
2941.       slen_full = i2d_SSL_SESSION(s->session, NULL);
                        ^
2942.       /*
2943.        * Some length values are 16 bits, so forget it if session is too

ssl/ssl_asn1.c:195:9: Assignment
  193.   
  194.       if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0)))
  195.           return 0;
                 ^
  196.   
  197.       memset(&as, 0, sizeof(as));

ssl/statem/statem_srvr.c:2941:5: Assignment
2939.   
2940.       /* get session encoding length */
2941.       slen_full = i2d_SSL_SESSION(s->session, NULL);
            ^
2942.       /*
2943.        * Some length values are 16 bits, so forget it if session is too

ssl/statem/statem_srvr.c:3034:10: Call
3032.       p += EVP_CIPHER_CTX_iv_length(&ctx);
3033.       /* Encrypt session data */
3034.       if (!EVP_EncryptUpdate(&ctx, p, &len, senc, slen))
                 ^
3035.           goto err;
3036.       p += len;

crypto/evp/evp_enc.c:289:1: <Offset trace>
287.   }
288.   
289. > int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
290.                         const unsigned char *in, int inl)
291.   {

crypto/evp/evp_enc.c:289:1: Parameter `inl`
  287.   }
  288.   
  289. > int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
  290.                         const unsigned char *in, int inl)
  291.   {

crypto/evp/evp_enc.c:289:1: <Length trace>
287.   }
288.   
289. > int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
290.                         const unsigned char *in, int inl)
291.   {

crypto/evp/evp_enc.c:289:1: Parameter `*in`
  287.   }
  288.   
  289. > int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
  290.                         const unsigned char *in, int inl)
  291.   {

crypto/evp/evp_enc.c:322:13: Array access: Offset added: [1, 65280] Size: [8, 522240] by call to `EVP_EncryptUpdate` 
  320.       if (i != 0) {
  321.           if (i + inl < bl) {
  322.               memcpy(&(ctx->buf[i]), in, inl);
                     ^
  323.               ctx->buf_len += inl;
  324.               *outl = 0;

int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
                      const unsigned char *in, int inl)
{
    int i, j, bl;
    if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
        i = ctx->cipher->do_cipher(ctx, out, in, inl);
        if (i < 0)
            return 0;
        else
            *outl = i;
        return 1;
    }
    if (inl <= 0) {
        *outl = 0;
        return inl == 0;
    }
    if (ctx->buf_len == 0 && (inl & (ctx->block_mask)) == 0) {
        if (ctx->cipher->do_cipher(ctx, out, in, inl)) {
            *outl = inl;
            return 1;
        } else {
            *outl = 0;
            return 0;
        }
    }
    i = ctx->buf_len;
    bl = ctx->cipher->block_size;
    OPENSSL_assert(bl <= (int)sizeof(ctx->buf));
    if (i != 0) {
        if (i + inl < bl) {
            memcpy(&(ctx->buf[i]), in, inl);
            ctx->buf_len += inl;
            *outl = 0;
            return 1;
        } else {
            j = bl - i;
            memcpy(&(ctx->buf[i]), in, j);
            if (!ctx->cipher->do_cipher(ctx, out, ctx->buf, bl))
                return 0;
            inl -= j;
            in += j;
            out += bl;
            *outl = bl;
        }
    } else
        *outl = 0;
    i = inl & (bl - 1);
    inl -= i;
    if (inl > 0) {
        if (!ctx->cipher->do_cipher(ctx, out, in, inl))
            return 0;
        *outl += inl;
    }
    if (i != 0)
        memcpy(ctx->buf, &(in[inl]), i);
    ctx->buf_len = i;
    return 1;
}
['int tls_construct_new_session_ticket(SSL *s)\n{\n    unsigned char *senc = NULL;\n    EVP_CIPHER_CTX ctx;\n    HMAC_CTX *hctx = NULL;\n    unsigned char *p, *macstart;\n    const unsigned char *const_p;\n    int len, slen_full, slen;\n    SSL_SESSION *sess;\n    unsigned int hlen;\n    SSL_CTX *tctx = s->initial_ctx;\n    unsigned char iv[EVP_MAX_IV_LENGTH];\n    unsigned char key_name[16];\n    slen_full = i2d_SSL_SESSION(s->session, NULL);\n    if (slen_full == 0 || slen_full > 0xFF00) {\n        ossl_statem_set_error(s);\n        return 0;\n    }\n    senc = OPENSSL_malloc(slen_full);\n    if (senc == NULL) {\n        ossl_statem_set_error(s);\n        return 0;\n    }\n    EVP_CIPHER_CTX_init(&ctx);\n    hctx = HMAC_CTX_new();\n    p = senc;\n    if (!i2d_SSL_SESSION(s->session, &p))\n        goto err;\n    const_p = senc;\n    sess = d2i_SSL_SESSION(NULL, &const_p, slen_full);\n    if (sess == NULL)\n        goto err;\n    sess->session_id_length = 0;\n    slen = i2d_SSL_SESSION(sess, NULL);\n    if (slen == 0 || slen > slen_full) {\n        SSL_SESSION_free(sess);\n        goto err;\n    }\n    p = senc;\n    if (!i2d_SSL_SESSION(sess, &p)) {\n        SSL_SESSION_free(sess);\n        goto err;\n    }\n    SSL_SESSION_free(sess);\n    if (!BUF_MEM_grow(s->init_buf,\n                      SSL_HM_HEADER_LENGTH(s) + 22 + EVP_MAX_IV_LENGTH +\n                      EVP_MAX_BLOCK_LENGTH + EVP_MAX_MD_SIZE + slen))\n        goto err;\n    p = ssl_handshake_start(s);\n    if (tctx->tlsext_ticket_key_cb) {\n        if (tctx->tlsext_ticket_key_cb(s, key_name, iv, &ctx, hctx, 1) < 0)\n            goto err;\n    } else {\n        if (RAND_bytes(iv, 16) <= 0)\n            goto err;\n        if (!EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL,\n                                tctx->tlsext_tick_aes_key, iv))\n            goto err;\n        if (!HMAC_Init_ex(hctx, tctx->tlsext_tick_hmac_key, 16,\n                          EVP_sha256(), NULL))\n            goto err;\n        memcpy(key_name, tctx->tlsext_tick_key_name, 16);\n    }\n    l2n(s->hit ? 0 : s->session->timeout, p);\n    p += 2;\n    macstart = p;\n    memcpy(p, key_name, 16);\n    p += 16;\n    memcpy(p, iv, EVP_CIPHER_CTX_iv_length(&ctx));\n    p += EVP_CIPHER_CTX_iv_length(&ctx);\n    if (!EVP_EncryptUpdate(&ctx, p, &len, senc, slen))\n        goto err;\n    p += len;\n    if (!EVP_EncryptFinal(&ctx, p, &len))\n        goto err;\n    p += len;\n    if (!HMAC_Update(hctx, macstart, p - macstart))\n        goto err;\n    if (!HMAC_Final(hctx, p, &hlen))\n        goto err;\n    EVP_CIPHER_CTX_cleanup(&ctx);\n    HMAC_CTX_free(hctx);\n    p += hlen;\n    len = p - ssl_handshake_start(s);\n    p = ssl_handshake_start(s) + 4;\n    s2n(len - 6, p);\n    if (!ssl_set_handshake_header(s, SSL3_MT_NEWSESSION_TICKET, len))\n        goto err;\n    OPENSSL_free(senc);\n    return 1;\n err:\n    OPENSSL_free(senc);\n    EVP_CIPHER_CTX_cleanup(&ctx);\n    HMAC_CTX_free(hctx);\n    ossl_statem_set_error(s);\n    return 0;\n}', 'int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)\n{\n    SSL_SESSION_ASN1 as;\n    ASN1_OCTET_STRING cipher;\n    unsigned char cipher_data[2];\n    ASN1_OCTET_STRING master_key, session_id, sid_ctx;\n#ifndef OPENSSL_NO_COMP\n    ASN1_OCTET_STRING comp_id;\n    unsigned char comp_id_data;\n#endif\n    ASN1_OCTET_STRING tlsext_hostname, tlsext_tick;\n#ifndef OPENSSL_NO_SRP\n    ASN1_OCTET_STRING srp_username;\n#endif\n#ifndef OPENSSL_NO_PSK\n    ASN1_OCTET_STRING psk_identity, psk_identity_hint;\n#endif\n    long l;\n    if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0)))\n        return 0;\n    memset(&as, 0, sizeof(as));\n    as.version = SSL_SESSION_ASN1_VERSION;\n    as.ssl_version = in->ssl_version;\n    if (in->cipher == NULL)\n        l = in->cipher_id;\n    else\n        l = in->cipher->id;\n    cipher_data[0] = ((unsigned char)(l >> 8L)) & 0xff;\n    cipher_data[1] = ((unsigned char)(l)) & 0xff;\n    ssl_session_oinit(&as.cipher, &cipher, cipher_data, 2);\n#ifndef OPENSSL_NO_COMP\n    if (in->compress_meth) {\n        comp_id_data = (unsigned char)in->compress_meth;\n        ssl_session_oinit(&as.comp_id, &comp_id, &comp_id_data, 1);\n    }\n#endif\n    ssl_session_oinit(&as.master_key, &master_key,\n                      in->master_key, in->master_key_length);\n    ssl_session_oinit(&as.session_id, &session_id,\n                      in->session_id, in->session_id_length);\n    ssl_session_oinit(&as.session_id_context, &sid_ctx,\n                      in->sid_ctx, in->sid_ctx_length);\n    as.time = in->time;\n    as.timeout = in->timeout;\n    as.verify_result = in->verify_result;\n    as.peer = in->peer;\n    ssl_session_sinit(&as.tlsext_hostname, &tlsext_hostname,\n                      in->tlsext_hostname);\n    if (in->tlsext_tick) {\n        ssl_session_oinit(&as.tlsext_tick, &tlsext_tick,\n                          in->tlsext_tick, in->tlsext_ticklen);\n    }\n    if (in->tlsext_tick_lifetime_hint > 0)\n        as.tlsext_tick_lifetime_hint = in->tlsext_tick_lifetime_hint;\n#ifndef OPENSSL_NO_PSK\n    ssl_session_sinit(&as.psk_identity_hint, &psk_identity_hint,\n                      in->psk_identity_hint);\n    ssl_session_sinit(&as.psk_identity, &psk_identity, in->psk_identity);\n#endif\n#ifndef OPENSSL_NO_SRP\n    ssl_session_sinit(&as.srp_username, &srp_username, in->srp_username);\n#endif\n    as.flags = in->flags;\n    return i2d_SSL_SESSION_ASN1(&as, pp);\n}', 'int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl)\n{\n    int i, j, bl;\n    if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {\n        i = ctx->cipher->do_cipher(ctx, out, in, inl);\n        if (i < 0)\n            return 0;\n        else\n            *outl = i;\n        return 1;\n    }\n    if (inl <= 0) {\n        *outl = 0;\n        return inl == 0;\n    }\n    if (ctx->buf_len == 0 && (inl & (ctx->block_mask)) == 0) {\n        if (ctx->cipher->do_cipher(ctx, out, in, inl)) {\n            *outl = inl;\n            return 1;\n        } else {\n            *outl = 0;\n            return 0;\n        }\n    }\n    i = ctx->buf_len;\n    bl = ctx->cipher->block_size;\n    OPENSSL_assert(bl <= (int)sizeof(ctx->buf));\n    if (i != 0) {\n        if (i + inl < bl) {\n            memcpy(&(ctx->buf[i]), in, inl);\n            ctx->buf_len += inl;\n            *outl = 0;\n            return 1;\n        } else {\n            j = bl - i;\n            memcpy(&(ctx->buf[i]), in, j);\n            if (!ctx->cipher->do_cipher(ctx, out, ctx->buf, bl))\n                return 0;\n            inl -= j;\n            in += j;\n            out += bl;\n            *outl = bl;\n        }\n    } else\n        *outl = 0;\n    i = inl & (bl - 1);\n    inl -= i;\n    if (inl > 0) {\n        if (!ctx->cipher->do_cipher(ctx, out, in, inl))\n            return 0;\n        *outl += inl;\n    }\n    if (i != 0)\n        memcpy(ctx->buf, &(in[inl]), i);\n    ctx->buf_len = i;\n    return 1;\n}']