<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2017-07-19 15:14 GMT+02:00 Thomas Bajer <span dir="ltr"><<a href="mailto:thomas.bajer@physec.de" target="_blank">thomas.bajer@physec.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br></blockquote><div><br></div><div>Hello,<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I would like to report an error message which valgrind throws the first<br>
time "SCardEstablishContext()" is called. The error message does not<br>
appear again when a second call to the function is done.<br>
<br>
Please have a look at the attached minimal example code. The program<br>
connects and disconnects to a smartcard two times. In order for the<br>
valgrind message to trigger, a smartcard has to be connected to the PC<br>
and the pcscd service has to be running.<br>
<br>
The code was linked with the newest stable release, 1.8.22.<br>
The code is compiled and linked on a FreeBSD system running FreeBSD 10.3<br>
(AMD64), the executable is then copied to a pfsense Box which also runs<br>
FreeBSD 10.3 with the same pcscd version.<br>
<br>
It would be great if a developer could look at this and commit a fix for<br>
this message.<br>
<br>
Below is the exampleConnect.c example, the build command and the<br>
valgrind error log.<br></blockquote><div><br></div><div>I can't reproduce your problem with a Debian stable system on amd64.<br></div><div>I get:<br>$ valgrind --leak-check=full ./sample <br>==4086== Memcheck, a memory error detector<br>==4086== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.<br>==4086== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info<br>==4086== Command: ./sample<br>==4086== <br>Establish context<br>List readers<br>Connect to card<br>Smartcard connected!<br>Disconnect card...<br>Free reader...<br>Release context...<br>Establish context<br>List readers<br>Connect to card<br>Smartcard connected!<br>Disconnect card...<br>Free reader...<br>Release context...<br>DONE!<br>==4086== <br>==4086== HEAP SUMMARY:<br>==4086==     in use at exit: 112 bytes in 4 blocks<br>==4086==   total heap usage: 21 allocs, 17 frees, 1,922 bytes allocated<br>==4086== <br>==4086== LEAK SUMMARY:<br>==4086==    definitely lost: 0 bytes in 0 blocks<br>==4086==    indirectly lost: 0 bytes in 0 blocks<br>==4086==      possibly lost: 0 bytes in 0 blocks<br>==4086==    still reachable: 112 bytes in 4 blocks<br>==4086==         suppressed: 0 bytes in 0 blocks<br>==4086== Reachable blocks (those to which a pointer was found) are not shown.<br>==4086== To see them, rerun with: --leak-check=full --show-leak-kinds=all<br>==4086== <br>==4086== For counts of detected and suppressed errors, rerun with: -v<br>==4086== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)<br><br><br></div><div>Please rebuild pcsc-lite using this patch and try again:<br>--- /tmp/lJqSB4_winscard_msg.c  2017-07-31 10:02:24.804416987 +0200<br>+++ src/winscard_msg.c  2017-07-31 09:59:09.565876305 +0200<br>@@ -130,6 +130,7 @@ INTERNAL int ClientSetupSession(uint32_t<br>    *pdwClientID = ret;<br> <br>    socketName = getSocketName();<br>+   memset(&svc_addr, 0, sizeof svc_addr);<br>    svc_addr.sun_family = AF_UNIX;<br>    strncpy(svc_addr.sun_path, socketName, sizeof(svc_addr.sun_path));<br> <br></div><div>Bye<br></div><div><br></div></div>-- <br><div class="gmail_signature"> Dr. Ludovic Rousseau</div>
</div></div>