ssl/t1_lib.c:1363: error: INTEGER_OVERFLOW_L2
  (0 - [-oo, 32]):unsigned64 by call to `EVP_DecryptUpdate`.
Showing all 7 steps of the trace


ssl/t1_lib.c:1363:25: Call
1361.       eticklen -= TLSEXT_KEYNAME_LENGTH + EVP_CIPHER_CTX_iv_length(ctx);
1362.       sdec = OPENSSL_malloc(eticklen);
1363.       if (sdec == NULL || EVP_DecryptUpdate(ctx, sdec, &slen, p,
                                ^
1364.                                             (int)eticklen) <= 0) {
1365.           OPENSSL_free(sdec);

crypto/evp/evp_enc.c:423:1: Parameter `ctx->cipher->block_size`
  421.   }
  422.   
  423. > int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
  424.                         const unsigned char *in, int inl)
  425.   {

crypto/evp/evp_enc.c:429:5: Assignment
  427.       unsigned int b;
  428.   
  429.       b = ctx->cipher->block_size;
             ^
  430.   
  431.       if (EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS))

crypto/evp/evp_enc.c:462:16: Call
  460.           /* see comment about PTRDIFF_T comparison above */
  461.           if (((PTRDIFF_T)out == (PTRDIFF_T)in)
  462.               || is_partially_overlapping(out, in, b)) {
                        ^
  463.               EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);
  464.               return 0;

crypto/evp/evp_enc.c:283:1: <RHS trace>
281.   #endif
282.   
283. > int is_partially_overlapping(const void *ptr1, const void *ptr2, int len)
284.   {
285.       PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2;

crypto/evp/evp_enc.c:283:1: Parameter `len`
    281.   #endif
    282.   
    283. > int is_partially_overlapping(const void *ptr1, const void *ptr2, int len)
    284.   {
    285.       PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2;

crypto/evp/evp_enc.c:292:50: Binary operation: (0 - [-oo, 32]):unsigned64 by call to `EVP_DecryptUpdate` 
    290.        */
    291.       int overlapped = (len > 0) & (diff != 0) & ((diff < (PTRDIFF_T)len) |
    292.                                                   (diff > (0 - (PTRDIFF_T)len)));
                                                            ^
    293.   
    294.       return overlapped;

int is_partially_overlapping(const void *ptr1, const void *ptr2, int len)
{
    PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2;
    int overlapped = (len > 0) & (diff != 0) & ((diff < (PTRDIFF_T)len) |
                                                (diff > (0 - (PTRDIFF_T)len)));
    return overlapped;
}
['SSL_TICKET_RETURN tls_decrypt_ticket(SSL *s, const unsigned char *etick,\n                                     size_t eticklen, const unsigned char *sess_id,\n                                     size_t sesslen, SSL_SESSION **psess)\n{\n    SSL_SESSION *sess;\n    unsigned char *sdec;\n    const unsigned char *p;\n    int slen, renew_ticket = 0, declen;\n    SSL_TICKET_RETURN ret = SSL_TICKET_FATAL_ERR_OTHER;\n    size_t mlen;\n    unsigned char tick_hmac[EVP_MAX_MD_SIZE];\n    HMAC_CTX *hctx = NULL;\n    EVP_CIPHER_CTX *ctx = NULL;\n    SSL_CTX *tctx = s->session_ctx;\n    if (eticklen < TLSEXT_KEYNAME_LENGTH + EVP_MAX_IV_LENGTH) {\n        ret = SSL_TICKET_NO_DECRYPT;\n        goto end;\n    }\n    hctx = HMAC_CTX_new();\n    if (hctx == NULL) {\n        ret = SSL_TICKET_FATAL_ERR_MALLOC;\n        goto end;\n    }\n    ctx = EVP_CIPHER_CTX_new();\n    if (ctx == NULL) {\n        ret = SSL_TICKET_FATAL_ERR_MALLOC;\n        goto end;\n    }\n    if (tctx->ext.ticket_key_cb) {\n        unsigned char *nctick = (unsigned char *)etick;\n        int rv = tctx->ext.ticket_key_cb(s, nctick,\n                                         nctick + TLSEXT_KEYNAME_LENGTH,\n                                         ctx, hctx, 0);\n        if (rv < 0) {\n            ret = SSL_TICKET_FATAL_ERR_OTHER;\n            goto end;\n        }\n        if (rv == 0) {\n            ret = SSL_TICKET_NO_DECRYPT;\n            goto end;\n        }\n        if (rv == 2)\n            renew_ticket = 1;\n    } else {\n        if (memcmp(etick, tctx->ext.tick_key_name,\n                   TLSEXT_KEYNAME_LENGTH) != 0) {\n            ret = SSL_TICKET_NO_DECRYPT;\n            goto end;\n        }\n        if (HMAC_Init_ex(hctx, tctx->ext.secure->tick_hmac_key,\n                         sizeof(tctx->ext.secure->tick_hmac_key),\n                         EVP_sha256(), NULL) <= 0\n            || EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL,\n                                  tctx->ext.secure->tick_aes_key,\n                                  etick + TLSEXT_KEYNAME_LENGTH) <= 0) {\n            ret = SSL_TICKET_FATAL_ERR_OTHER;\n            goto end;\n        }\n        if (SSL_IS_TLS13(s))\n            renew_ticket = 1;\n    }\n    mlen = HMAC_size(hctx);\n    if (mlen == 0) {\n        ret = SSL_TICKET_FATAL_ERR_OTHER;\n        goto end;\n    }\n    if (eticklen <=\n        TLSEXT_KEYNAME_LENGTH + EVP_CIPHER_CTX_iv_length(ctx) + mlen) {\n        ret = SSL_TICKET_NO_DECRYPT;\n        goto end;\n    }\n    eticklen -= mlen;\n    if (HMAC_Update(hctx, etick, eticklen) <= 0\n        || HMAC_Final(hctx, tick_hmac, NULL) <= 0) {\n        ret = SSL_TICKET_FATAL_ERR_OTHER;\n        goto end;\n    }\n    if (CRYPTO_memcmp(tick_hmac, etick + eticklen, mlen)) {\n        ret = SSL_TICKET_NO_DECRYPT;\n        goto end;\n    }\n    p = etick + TLSEXT_KEYNAME_LENGTH + EVP_CIPHER_CTX_iv_length(ctx);\n    eticklen -= TLSEXT_KEYNAME_LENGTH + EVP_CIPHER_CTX_iv_length(ctx);\n    sdec = OPENSSL_malloc(eticklen);\n    if (sdec == NULL || EVP_DecryptUpdate(ctx, sdec, &slen, p,\n                                          (int)eticklen) <= 0) {\n        OPENSSL_free(sdec);\n        ret = SSL_TICKET_FATAL_ERR_OTHER;\n        goto end;\n    }\n    if (EVP_DecryptFinal(ctx, sdec + slen, &declen) <= 0) {\n        OPENSSL_free(sdec);\n        ret = SSL_TICKET_NO_DECRYPT;\n        goto end;\n    }\n    slen += declen;\n    p = sdec;\n    sess = d2i_SSL_SESSION(NULL, &p, slen);\n    slen -= p - sdec;\n    OPENSSL_free(sdec);\n    if (sess) {\n        if (slen != 0) {\n            SSL_SESSION_free(sess);\n            ret = SSL_TICKET_NO_DECRYPT;\n            goto end;\n        }\n        if (sesslen) {\n            memcpy(sess->session_id, sess_id, sesslen);\n            sess->session_id_length = sesslen;\n        }\n        *psess = sess;\n        if (renew_ticket)\n            ret = SSL_TICKET_SUCCESS_RENEW;\n        else\n            ret = SSL_TICKET_SUCCESS;\n        goto end;\n    }\n    ERR_clear_error();\n    ret = SSL_TICKET_NO_DECRYPT;\n end:\n    EVP_CIPHER_CTX_free(ctx);\n    HMAC_CTX_free(hctx);\n    if (s->session_ctx->decrypt_ticket_cb != NULL) {\n        size_t keyname_len = eticklen;\n        if (keyname_len > TLSEXT_KEYNAME_LENGTH)\n            keyname_len = TLSEXT_KEYNAME_LENGTH;\n        ret = s->session_ctx->decrypt_ticket_cb(s, *psess, etick, keyname_len,\n                                                ret,\n                                                s->session_ctx->ticket_cb_data);\n    }\n    switch (ret) {\n    case SSL_TICKET_NO_DECRYPT:\n    case SSL_TICKET_SUCCESS_RENEW:\n    case SSL_TICKET_EMPTY:\n        s->ext.ticket_expected = 1;\n    case SSL_TICKET_SUCCESS:\n    case SSL_TICKET_NONE:\n        return ret;\n    }\n    return SSL_TICKET_FATAL_ERR_OTHER;\n}', 'int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl)\n{\n    int fix_len, cmpl = inl;\n    unsigned int b;\n    b = ctx->cipher->block_size;\n    if (EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS))\n        cmpl = (cmpl + 7) / 8;\n    if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {\n        if (b == 1 && is_partially_overlapping(out, in, cmpl)) {\n            EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);\n            return 0;\n        }\n        fix_len = ctx->cipher->do_cipher(ctx, out, in, inl);\n        if (fix_len < 0) {\n            *outl = 0;\n            return 0;\n        } else\n            *outl = fix_len;\n        return 1;\n    }\n    if (inl <= 0) {\n        *outl = 0;\n        return inl == 0;\n    }\n    if (ctx->flags & EVP_CIPH_NO_PADDING)\n        return EVP_EncryptUpdate(ctx, out, outl, in, inl);\n    OPENSSL_assert(b <= sizeof(ctx->final));\n    if (ctx->final_used) {\n        if (((PTRDIFF_T)out == (PTRDIFF_T)in)\n            || is_partially_overlapping(out, in, b)) {\n            EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);\n            return 0;\n        }\n        memcpy(out, ctx->final, b);\n        out += b;\n        fix_len = 1;\n    } else\n        fix_len = 0;\n    if (!EVP_EncryptUpdate(ctx, out, outl, in, inl))\n        return 0;\n    if (b > 1 && !ctx->buf_len) {\n        *outl -= b;\n        ctx->final_used = 1;\n        memcpy(ctx->final, &out[*outl], b);\n    } else\n        ctx->final_used = 0;\n    if (fix_len)\n        *outl += b;\n    return 1;\n}', 'int is_partially_overlapping(const void *ptr1, const void *ptr2, int len)\n{\n    PTRDIFF_T diff = (PTRDIFF_T)ptr1-(PTRDIFF_T)ptr2;\n    int overlapped = (len > 0) & (diff != 0) & ((diff < (PTRDIFF_T)len) |\n                                                (diff > (0 - (PTRDIFF_T)len)));\n    return overlapped;\n}']