<!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 style="color: #777777;">
<a href="https://gitlab.com/rockdaboot">Tim Rühsen</a>
commented:
</p>
<div style="">
<p dir="auto">Valgrind doens't complain when built with -O0, the assembler (L122/strcmp starts at the arrow):</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">   0x00005555555554f8 <+803>:   mov    $0x76,%esi</span>
<span id="LC2" class="line" lang="plaintext">   0x00005555555554fd <+808>:   lea    0xb14(%rip),%rdi        # 0x555555556018</span>
<span id="LC3" class="line" lang="plaintext">   0x0000555555555504 <+815>:   mov    $0x0,%eax</span>
<span id="LC4" class="line" lang="plaintext">   0x0000555555555509 <+820>:   callq  0x555555555060 <printf@plt></span>
<span id="LC5" class="line" lang="plaintext">   0x000055555555550e <+825>:   mov    $0x1,%edi</span>
<span id="LC6" class="line" lang="plaintext">   0x0000555555555513 <+830>:   callq  0x5555555550b0 <exit@plt></span>
<span id="LC7" class="line" lang="plaintext">=> 0x0000555555555518 <+835>:   lea    -0x4b0(%rbp),%rax</span>
<span id="LC8" class="line" lang="plaintext">   0x000055555555551f <+842>:   lea    0xb4c(%rip),%rsi        # 0x555555556072</span>
<span id="LC9" class="line" lang="plaintext">   0x0000555555555526 <+849>:   mov    %rax,%rdi</span>
<span id="LC10" class="line" lang="plaintext">   0x0000555555555529 <+852>:   callq  0x555555555080 <strcmp@plt></span>
<span id="LC11" class="line" lang="plaintext">   0x000055555555552e <+857>:   test   %eax,%eax</span>
<span id="LC12" class="line" lang="plaintext">   0x0000555555555530 <+859>:   jne    0x555555555552 <main+893></span>
<span id="LC13" class="line" lang="plaintext">   0x0000555555555532 <+861>:   mov    $0x7c,%esi</span>
<span id="LC14" class="line" lang="plaintext">   0x0000555555555537 <+866>:   lea    0xada(%rip),%rdi        # 0x555555556018</span></code></pre>
<p dir="auto">In comparison, the code generated by gcc 9 with -O2 (see above) just accesses 16 bytes of stack memory for an optimized version of <code>strcmp</code>. So no wonder that valgrind complains, though it is a false positive.</p>
<p dir="auto">To calm down valgrind, we can <code>*data = 0</code> before <code>asn1_read_value()</code>. This just 'marks' <code>data</code> as being initialized. Alternatively, we have to add/create a valgrind suppression.</p>
</div>


</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#note_237741131">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/ae626df9ef4d652a3c4da2a2e9528382/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#note_237741131"}}</script>


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