<!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: #666;">
<a href="https://gitlab.com/tatsuhiro-t">Tatsuhiro Tsujikawa</a> created an issue: <a href="https://gitlab.com/gnutls/gnutls/-/issues/1319">#1319</a>
</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">When received data is too short to contain a message header, they are temporarily buffered in somewhere and when the next segment is arrived, they are gathered into one buffer (linearized).  I'm specifically looking at this code:
<a href="https://gitlab.com/gnutls/gnutls/-/blob/7f3ea9acc2a2da1d697d423514dfa9c3b56acb15/lib/buffers.c#L1259">https://gitlab.com/gnutls/gnutls/-/blob/7f3ea9acc2a2da1d697d423514dfa9c3b56acb15/lib/buffers.c#L1259</a></p>
<p dir="auto">The problem is, when the buffers are linearized, mbuffer_st type is cleared.  Next time we hit <a href="https://gitlab.com/gnutls/gnutls/-/blob/7f3ea9acc2a2da1d697d423514dfa9c3b56acb15/lib/buffers.c#L1217">https://gitlab.com/gnutls/gnutls/-/blob/7f3ea9acc2a2da1d697d423514dfa9c3b56acb15/lib/buffers.c#L1217</a>, the check fails, and the endpoint sends fatal alert with unexpected message.</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.7.3</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>
<h2 dir="auto">
<a id="user-content-how-reproducible" class="anchor" href="#how-reproducible" aria-hidden="true"></a>How reproducible:</h2>
<p dir="auto">Steps to Reproduce:</p>
<p dir="auto">I think feeding data ends in the middle of a message header to gnutls_session_t via gnutls_handshake_write would trigger this bug.
For myself, I discovered it when testing client certificate authentication as QUIC client.</p>
<h2 dir="auto">
<a id="user-content-actual-results" class="anchor" href="#actual-results" aria-hidden="true"></a>Actual results:</h2>
<h2 dir="auto">
<a id="user-content-expected-results" class="anchor" href="#expected-results" aria-hidden="true"></a>Expected results:</h2>

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

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1319">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/f0461557ea375209f34a0238bb97ff56/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/1319"}}</script>


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