<!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/dueno">Daiki Ueno</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">Maybe this is a false-positive in valgrind, but it reports "Conditional jump or move depends on uninitialised value(s)" when I access a certain position of CHOICE node name returned by <code>asn1_read_value</code>, i.e.,</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">data_size</span> <span class="o">=</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">data</span><span class="p">);</span></span>
<span id="LC2" class="line" lang="c">  <span class="n">result</span> <span class="o">=</span> <span class="n">asn1_read_value</span> <span class="p">(</span><span class="n">node2</span><span class="p">,</span> <span class="s">""</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">&</span><span class="n">data_size</span><span class="p">);</span></span>
<span id="LC3" class="line" lang="c">  <span class="k">if</span> <span class="p">(</span><span class="n">result</span> <span class="o">!=</span> <span class="n">ASN1_SUCCESS</span><span class="p">)</span></span>
<span id="LC4" class="line" lang="c">    <span class="p">{</span></span>
<span id="LC5" class="line" lang="c">      <span class="n">printf</span> <span class="p">(</span><span class="s">"error in %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">__LINE__</span><span class="p">);</span></span>
<span id="LC6" class="line" lang="c">      <span class="n">exit</span> <span class="p">(</span><span class="mi">1</span><span class="p">);</span></span>
<span id="LC7" class="line" lang="c">    <span class="p">}</span></span>
<span id="LC8" class="line" lang="c"></span>
<span id="LC9" class="line" lang="c">  <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span> <span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="s">"012345678901234"</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="c1">// <--</span></span>
<span id="LC10" class="line" lang="c">    <span class="p">{</span></span>
<span id="LC11" class="line" lang="c">      <span class="n">printf</span> <span class="p">(</span><span class="s">"error in %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">__LINE__</span><span class="p">);</span></span>
<span id="LC12" class="line" lang="c">      <span class="n">exit</span> <span class="p">(</span><span class="mi">1</span><span class="p">);</span></span>
<span id="LC13" class="line" lang="c">    <span class="p">}</span></span></code></pre>
<p dir="auto">Interestingly, valgrind doesn't complain if the needle is shorter than 16 nor the program is compiled with -O0.</p>
<h2 dir="auto">
<a id="user-content-version-of-libtasn1-used" class="anchor" href="#version-of-libtasn1-used" aria-hidden="true"></a>Version of libtasn1 used:</h2>
<p dir="auto">git master</p>
<h2 dir="auto">
<a id="user-content-distributor-of-libtasn1-eg-ubuntu-fedora-rhel" class="anchor" href="#distributor-of-libtasn1-eg-ubuntu-fedora-rhel" aria-hidden="true"></a>Distributor of libtasn1 (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>
<ul dir="auto">
<li>Apply <a href="https://gitlab.com/gnutls/libtasn1/uploads/8308e39fc5d84559862c5c0cfbdff6be/libtasn1-valgrind.patch">libtasn1-valgrind.patch</a> to <code>tests/Test_choice.c</code> and do the following:</li>
</ul>
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span id="LC1" class="line" lang="shell"><span class="nv">$ </span>./configure <span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">"-O2 -g3 -Wall"</span></span>
<span id="LC2" class="line" lang="shell"><span class="nv">$ </span>make</span>
<span id="LC3" class="line" lang="shell"><span class="nv">$ </span>make check <span class="nv">LOG_COMPILER</span><span class="o">=</span><span class="s2">"valgrind --error-exitcode=1"</span> <span class="nv">TESTS</span><span class="o">=</span>Test_choice <span class="nv">V</span><span class="o">=</span>1</span>
<span id="LC4" class="line" lang="shell"><span class="nv">$ </span><span class="nb">cat </span>tests/Test_choice.log</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">The log contains:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">==1297== Conditional jump or move depends on uninitialised value(s)</span>
<span id="LC2" class="line" lang="plaintext">==1297==    at 0x4013DD: main (Test_choice.c:122)</span></code></pre>
<h2 dir="auto">
<a id="user-content-expected-results" class="anchor" href="#expected-results" aria-hidden="true"></a>Expected results:</h2>
<p dir="auto">The log shouldn't contain the error.</p>

</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/libtasn1/issues/9">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/efa1a2987e699bd54e79ee64e597b802/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/libtasn1/issues/9"}}</script>


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