<!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=utf-8" 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: #777777;">
Project:Branches: Lekensteyn/gnutls:fix-token-info-modname → gnutls/gnutls:master
</p>

<div>
<p dir="auto">Fixes a memleak and some inconsistent behavior when the output buffer is too short.
Not sure if it is worth documenting presence of such bugs in the function documentation, I noticed a crash when using this pattern:</p>
<pre class="code highlight js-syntax-highlight c" lang="c" v-pre="true"><code><span id="LC1" class="line" lang="c"><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></span>
<span id="LC2" class="line" lang="c"><span class="n">ret</span> <span class="o">=</span> <span class="n">gnutls_pkcs11_token_get_info</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">GNUTLS_PKCS11_TOKEN_MODNAME</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="o">&</span><span class="n">size</span><span class="p">);</span></span>
<span id="LC3" class="line" lang="c"><span class="cm">/* error handling for ret */</span></span>
<span id="LC4" class="line" lang="c"><span class="n">buffer</span> <span class="o">=</span> <span class="n">g_malloc</span><span class="p">(</span><span class="n">size</span><span class="p">);</span></span>
<span id="LC5" class="line" lang="c"><span class="n">ret</span> <span class="o">=</span> <span class="n">gnutls_pkcs11_token_get_info</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">GNUTLS_PKCS11_TOKEN_MODNAME</span><span class="p">,</span> <span class="n">buffer</span><span class="p">,</span> <span class="o">&</span><span class="n">size</span><span class="p">);</span></span></code></pre>
<p dir="auto">Note that with the "consistency fix", the above has to be changed to this:</p>
<pre class="code highlight js-syntax-highlight c" lang="c" v-pre="true"><code><span id="LC1" class="line" lang="c"><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></span>
<span id="LC2" class="line" lang="c"><span class="n">ret</span> <span class="o">=</span> <span class="n">gnutls_pkcs11_token_get_info</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">GNUTLS_PKCS11_TOKEN_MODNAME</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="o">&</span><span class="n">size</span><span class="p">);</span></span>
<span id="LC3" class="line" lang="c"><span class="cm">/* error handling for ret */</span></span>
<span id="LC4" class="line" lang="c"><span class="o">++</span><span class="n">size</span><span class="p">;</span>  <span class="cm">/* include memory for NULL terminator */</span></span>
<span id="LC5" class="line" lang="c"><span class="n">buffer</span> <span class="o">=</span> <span class="n">g_malloc</span><span class="p">(</span><span class="n">size</span><span class="p">);</span></span>
<span id="LC6" class="line" lang="c"><span class="n">ret</span> <span class="o">=</span> <span class="n">gnutls_pkcs11_token_get_info</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">GNUTLS_PKCS11_TOKEN_MODNAME</span><span class="p">,</span> <span class="n">buffer</span><span class="p">,</span> <span class="o">&</span><span class="n">size</span><span class="p">);</span></span></code></pre>
<h2 dir="auto">
<a id="user-content-checklist" class="anchor" href="#checklist" aria-hidden="true"></a>Checklist</h2>
<ul class="task-list" dir="auto">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Code modified for feature</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Test suite updated with functionality tests</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Test suite updated with negative tests</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Documentation updated / NEWS entry present (for non-trivial changes)</li>
</ul>
<h2 dir="auto">
<a id="user-content-reviewers-checklist" class="anchor" href="#reviewers-checklist" aria-hidden="true"></a>Reviewer's checklist:</h2>
<ul class="task-list" dir="auto">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Any issues marked for closing are addressed</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> There is a test suite reasonably covering new functionality or modifications</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Function naming, parameters, return values, types, etc., are consistent and according to <code>CONTRIBUTION.md</code>
</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> This feature/change has adequate documentation added</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> No obvious mistakes in the code</li>
</ul>
</div>

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

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/merge_requests/827">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/a13b0ab780643abcf40027057979d99b/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 Merge request","url":"https://gitlab.com/gnutls/gnutls/merge_requests/827"}}</script>
</p>
</div>
</body>
</html>