<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>


<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">

<p class="details" style="font-style: italic; color: #777;">
<a href="https://gitlab.com/rrivers2">rrivers2</a> created an issue:
</p>
<div></div>
<h2 dir="auto">
<a id="user-content-description-of-problem" class="anchor" href="#description-of-problem" aria-hidden="true"></a>Description of problem:</h2>
<p dir="auto">GnuTLS based applications fail to connect to pop.verizon.net:995</p>
<h2 dir="auto">
<a id="user-content-version-of-gnutls-used" class="anchor" href="#version-of-gnutls-used" aria-hidden="true"></a>Version of gnutls used:</h2>
<p dir="auto">3.5.18</p>
<h2 dir="auto">
<a id="user-content-distributor-of-gnutls-eg-ubuntu-fedora-rhel" class="anchor" href="#distributor-of-gnutls-eg-ubuntu-fedora-rhel" aria-hidden="true"></a>Distributor of gnutls (e.g., Ubuntu, Fedora, RHEL)</h2>
<p dir="auto">Ubuntu 18.04.4</p>
<h2 dir="auto">
<a id="user-content-how-reproducible" class="anchor" href="#how-reproducible" aria-hidden="true"></a>How reproducible:</h2>
<p dir="auto">Consistently reproducible</p>
<h2 dir="auto">
<a id="user-content-steps-to-reproduce" class="anchor" href="#steps-to-reproduce" aria-hidden="true"></a>Steps to Reproduce:</h2>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">gnutls-cli -d 99 pop.verizon.net:995</span></code></pre>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">1. run evolution, </span>
<span id="LC2" class="line" lang="plaintext">2. configure a pop connection (no account needed since its a handshake failure)</span>
<span id="LC3" class="line" lang="plaintext">   Server: pop.verizon.net</span>
<span id="LC4" class="line" lang="plaintext">   Port: 995</span>
<span id="LC5" class="line" lang="plaintext">   User: test</span>
<span id="LC6" class="line" lang="plaintext">   Encryption method: TLS on a dedicated port</span>
<span id="LC7" class="line" lang="plaintext">   Authentication: password</span>
<span id="LC8" class="line" lang="plaintext">3. click on send/receive</span></code></pre>
<h2 dir="auto">
<a id="user-content-actual-results" class="anchor" href="#actual-results" aria-hidden="true"></a>Actual results:</h2>
<p dir="auto"><a href="https://gitlab.com/gnutls/gnutls/uploads/4566006cb094e63c3c37e32045feccba/debug.txt" data-link="true" class="gfm">debug.txt</a></p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">Full output attached as debug.txt</span>
<span id="LC2" class="line" lang="plaintext">the last packet received and sent:</span>
<span id="LC3" class="line" lang="plaintext"></span>
<span id="LC4" class="line" lang="plaintext">|<5>| REC[0x555555b215f0]: SSL 3.3 Handshake packet received. Epoch 0, length: 10</span>
<span id="LC5" class="line" lang="plaintext">|<5>| REC[0x555555b215f0]: Expected Packet Handshake(22)</span>
<span id="LC6" class="line" lang="plaintext">|<5>| REC[0x555555b215f0]: Received Packet Handshake(22) with length: 10</span>
<span id="LC7" class="line" lang="plaintext">|<10>| READ: Got 10 bytes from 0x3</span>
<span id="LC8" class="line" lang="plaintext">|<10>| READ: read 10 bytes from 0x3</span>
<span id="LC9" class="line" lang="plaintext">|<10>| RB: Have 5 bytes into buffer. Adding 10 bytes.</span>
<span id="LC10" class="line" lang="plaintext">|<10>| RB: Requested 15 bytes</span>
<span id="LC11" class="line" lang="plaintext">|<5>| REC[0x555555b215f0]: Decrypted Packet[1] Handshake(22) with length: 10</span>
<span id="LC12" class="line" lang="plaintext">|<13>| BUF[REC]: Inserted 10 bytes of Data(22)</span>
<span id="LC13" class="line" lang="plaintext">|<4>| HSK[0x555555b215f0]: NEW SESSION TICKET (4) was received. Length 6[6], frag offset 0, frag length: 6, sequence: 0</span>
<span id="LC14" class="line" lang="plaintext">|<3>| ASSERT: session_ticket.c[_gnutls_recv_new_session_ticket]:767</span>
<span id="LC15" class="line" lang="plaintext">|<3>| ASSERT: handshake.c[handshake_client]:2979</span>
<span id="LC16" class="line" lang="plaintext">*** Fatal error: Internal error in memory allocation.</span>
<span id="LC17" class="line" lang="plaintext">|<5>| REC: Sending Alert[2|80] - Internal error</span>
<span id="LC18" class="line" lang="plaintext">|<5>| REC[0x555555b215f0]: Preparing Packet Alert(21) with length: 2 and min pad: 0</span>
<span id="LC19" class="line" lang="plaintext">|<9>| ENC[0x555555b215f0]: cipher: AES-256-GCM, MAC: AEAD, Epoch: 1</span>
<span id="LC20" class="line" lang="plaintext">|<11>| WRITE: enqueued 31 bytes for 0x3. Total 31 bytes.</span>
<span id="LC21" class="line" lang="plaintext">|<11>| WRITE FLUSH: 31 bytes in buffer.</span>
<span id="LC22" class="line" lang="plaintext">|<11>| WRITE: wrote 31 bytes, 0 bytes left.</span>
<span id="LC23" class="line" lang="plaintext">|<5>| REC[0x555555b215f0]: Sent Packet[2] Alert(21) in epoch 1 and length: 31</span>
<span id="LC24" class="line" lang="plaintext">*** handshake has failed: Internal error in memory allocation.</span></code></pre>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">Evolution will display the error message "Error performing TLS handshake: Internal error in memory allocation."</span></code></pre>
<h2 dir="auto">
<a id="user-content-expected-results" class="anchor" href="#expected-results" aria-hidden="true"></a>Expected results:</h2>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">gnutls-cli should connect to the server</span></code></pre>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">evolution should connect and download new email if you have an account</span></code></pre>
<p dir="auto">The issue appears to be in the function _gnutls_recv_new_session_ticket around line 758 of session_ticket.c. The code reads two bytes and assigns the result to the variable ticket_len. Unfortunately this value is zero. A few lines later when the variable is used in a call to gnutls_realloc_fast(), the call fails and the code returns GNUTLS_E_MEMORY_ERROR.
Wireshark confirms the new session ticket returned by the server has length 0:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">Handshake Protocol: New Session Ticket</span>
<span id="LC2" class="line" lang="plaintext">    Handshake Type: New Session Ticket (4)</span>
<span id="LC3" class="line" lang="plaintext">    Length: 6</span>
<span id="LC4" class="line" lang="plaintext">    TLS Session Ticket</span>
<span id="LC5" class="line" lang="plaintext">        Session Ticket Lifetime Hint: 60 seconds (1 minute)</span>
<span id="LC6" class="line" lang="plaintext">        Session Ticket Length: 0</span>
<span id="LC7" class="line" lang="plaintext">        Session Ticket: <MISSING></span></code></pre>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/997">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/-/sent_notifications/4b2310da0a87217f625241cb7a341ca3/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/-/issues/997"}}</script>


</p>
</div>
</body>
</html>