<!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/dueno">Daiki Ueno</a>
commented on a
<a href="https://gitlab.com/gnutls/libtasn1/issues/9#note_193341717">discussion</a>:
</p>
<div style="">
<p dir="auto">Looks like so and if I replace <code>strcmp</code> with a length check + <code>memcmp</code> the error is gone.</p>
<p dir="auto">Here is the disassembly gathered by Mark Wielaard:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">$ ASN1CHOICE=choice.asn libtool --mode=execute valgrind --vgdb-error=0 ./Test_choice</span>
<span id="LC2" class="line" lang="plaintext">==18694== Memcheck, a memory error detector</span>
<span id="LC3" class="line" lang="plaintext">==18694== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.</span>
<span id="LC4" class="line" lang="plaintext">==18694== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info</span>
<span id="LC5" class="line" lang="plaintext">==18694== Command: ./Test_choice</span>
<span id="LC6" class="line" lang="plaintext">==18694== </span>
<span id="LC7" class="line" lang="plaintext">==18694== (action at startup) vgdb me ... </span>
<span id="LC8" class="line" lang="plaintext">==18694== </span>
<span id="LC9" class="line" lang="plaintext">==18694== TO DEBUG THIS PROCESS USING GDB: start GDB like this</span>
<span id="LC10" class="line" lang="plaintext">==18694== /path/to/gdb ./Test_choice</span>
<span id="LC11" class="line" lang="plaintext">==18694== and then give GDB the following command</span>
<span id="LC12" class="line" lang="plaintext">==18694== target remote | /usr/libexec/valgrind/../../bin/vgdb --pid=18694</span>
<span id="LC13" class="line" lang="plaintext">==18694== --pid is optional if only one valgrind process is running</span>
<span id="LC14" class="line" lang="plaintext">==18694== </span>
<span id="LC15" class="line" lang="plaintext">==18694== Conditional jump or move depends on uninitialised value(s)</span>
<span id="LC16" class="line" lang="plaintext">==18694== at 0x40128D: main (Test_choice.c:122)</span>
<span id="LC17" class="line" lang="plaintext">==18694== </span>
<span id="LC18" class="line" lang="plaintext">==18694== (action on error) vgdb me ... </span>
<span id="LC19" class="line" lang="plaintext"></span>
<span id="LC20" class="line" lang="plaintext">...</span>
<span id="LC21" class="line" lang="plaintext"></span>
<span id="LC22" class="line" lang="plaintext">$ ASN1CHOICE=choice.asn libtool --mode=execute gdb ./Test_choice</span>
<span id="LC23" class="line" lang="plaintext">[...]</span>
<span id="LC24" class="line" lang="plaintext">Reading symbols from ./Test_choice...</span>
<span id="LC25" class="line" lang="plaintext">(gdb) target remote | vgdb</span>
<span id="LC26" class="line" lang="plaintext">Remote debugging using | vgdb</span>
<span id="LC27" class="line" lang="plaintext">relaying data between gdb and process 18694</span>
<span id="LC28" class="line" lang="plaintext">warning: remote target does not support file transfer, attempting to access files from local filesystem.</span>
<span id="LC29" class="line" lang="plaintext">(gdb) c</span>
<span id="LC30" class="line" lang="plaintext">Continuing.</span>
<span id="LC31" class="line" lang="plaintext"></span>
<span id="LC32" class="line" lang="plaintext">Program received signal SIGTRAP, Trace/breakpoint trap.</span>
<span id="LC33" class="line" lang="plaintext">0x000000000040128d in main (argc=<optimized out>, argv=<optimized out>)</span>
<span id="LC34" class="line" lang="plaintext"> at Test_choice.c:122</span>
<span id="LC35" class="line" lang="plaintext">122 if (strcmp (data, "012345678901234") == 0)</span>
<span id="LC36" class="line" lang="plaintext">(gdb) disassemble </span>
<span id="LC37" class="line" lang="plaintext">Dump of assembler code for function main:</span>
<span id="LC38" class="line" lang="plaintext">[...]</span>
<span id="LC39" class="line" lang="plaintext"> 0x0000000000401216 <+326>: mov 0x4(%rsp),%edx</span>
<span id="LC40" class="line" lang="plaintext"> 0x000000000040121a <+330>: lea 0x20(%rsp),%rcx</span>
<span id="LC41" class="line" lang="plaintext"> 0x000000000040121f <+335>: lea 0x18(%rsp),%rdi</span>
<span id="LC42" class="line" lang="plaintext"> 0x0000000000401224 <+340>: lea 0xa0(%rsp),%rsi</span>
<span id="LC43" class="line" lang="plaintext"> 0x000000000040122c <+348>: callq 0x401080 <asn1_der_decoding@plt></span>
<span id="LC44" class="line" lang="plaintext"> 0x0000000000401231 <+353>: test %eax,%eax</span>
<span id="LC45" class="line" lang="plaintext"> 0x0000000000401233 <+355>: jne 0x4012ca <main+506></span>
<span id="LC46" class="line" lang="plaintext"> 0x0000000000401239 <+361>: mov 0x18(%rsp),%rdi</span>
<span id="LC47" class="line" lang="plaintext"> 0x000000000040123e <+366>: lea 0x4(%rsp),%rcx</span>
<span id="LC48" class="line" lang="plaintext"> 0x0000000000401243 <+371>: lea 0xa0(%rsp),%rdx</span>
<span id="LC49" class="line" lang="plaintext"> 0x000000000040124b <+379>: mov $0x402030,%esi</span>
<span id="LC50" class="line" lang="plaintext"> 0x0000000000401250 <+384>: movl $0x400,0x4(%rsp)</span>
<span id="LC51" class="line" lang="plaintext"> 0x0000000000401258 <+392>: callq 0x401040 <asn1_read_value@plt></span>
<span id="LC52" class="line" lang="plaintext"> 0x000000000040125d <+397>: test %eax,%eax</span>
<span id="LC53" class="line" lang="plaintext"> 0x000000000040125f <+399>: jne 0x4012c3 <main+499></span>
<span id="LC54" class="line" lang="plaintext"> 0x0000000000401261 <+401>: movabs $0x34333231303938,%rdx</span>
<span id="LC55" class="line" lang="plaintext"> 0x000000000040126b <+411>: xor 0xa8(%rsp),%rdx</span>
<span id="LC56" class="line" lang="plaintext"> 0x0000000000401273 <+419>: mov $0x7c,%esi</span>
<span id="LC57" class="line" lang="plaintext"> 0x0000000000401278 <+424>: movabs $0x3736353433323130,%rax</span>
<span id="LC58" class="line" lang="plaintext"> 0x0000000000401282 <+434>: xor 0xa0(%rsp),%rax</span>
<span id="LC59" class="line" lang="plaintext"> 0x000000000040128a <+442>: or %rax,%rdx</span>
<span id="LC60" class="line" lang="plaintext">=> 0x000000000040128d <+445>: jne 0x4012a5 <main+469></span>
<span id="LC61" class="line" lang="plaintext"> 0x000000000040128f <+447>: mov $0x402024,%edi</span>
<span id="LC62" class="line" lang="plaintext"> 0x0000000000401294 <+452>: xor %eax,%eax</span>
<span id="LC63" class="line" lang="plaintext"> 0x0000000000401296 <+454>: callq 0x401060 <printf@plt></span>
<span id="LC64" class="line" lang="plaintext"> 0x000000000040129b <+459>: mov $0x1,%edi</span>
<span id="LC65" class="line" lang="plaintext"> 0x00000000004012a0 <+464>: callq 0x4010a0 <exit@plt></span>
<span id="LC66" class="line" lang="plaintext"></span></code></pre>
</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_193341717">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/29424ee1fbf6336b1a4c0127efd49a3a/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_193341717"}}</script>
</p>
</div>
</body>
</html>