SCardConnect: socketcall.sendto(msg) points to uninitialized byte(s)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

SCardConnect: socketcall.sendto(msg) points to uninitialized byte(s)

Andrey R
Hi. 
Valgrind detected usage of uninitialized memory in SCardConnect:

==19635== Memcheck, a memory error detector
==19635== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==19635== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==19635== Command: /usr/rtests/bin/Pkcs11UnitTest.X64 pkcs11_common
==19635==
Running pkcs11_common
pkcs11_common::testGetInfo==19635== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==19635== at 0x605A1F7: send (send.c:32)
==19635== by 0xBC47CE6: ??? (in /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0)
==19635== by 0xBC47E22: ??? (in /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0)
==19635== by 0xBC43BBE: SCardConnect (in /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0)
...

connect_struct.szReader involved. Patch for resolving the problem:
root@test-x64-ub13:/tmp# diff -u pcsc-lite-1.8.16/src/winscard_clnt.c{,.patched}
--- pcsc-lite-1.8.16/src/winscard_clnt.c 2016-03-12 23:03:09.000000000 +0400
+++ pcsc-lite-1.8.16/src/winscard_clnt.c.patched 2016-04-07 16:20:28.193294111 +0400
@@ -764,7 +764,7 @@
LPDWORD pdwActiveProtocol)
{
LONG rv;
- struct connect_struct scConnectStruct;
+ struct connect_struct scConnectStruct = { 0 };
SCONTEXTMAP * currentContextMap;

PROFILE_START

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: SCardConnect: socketcall.sendto(msg) points to uninitialized byte(s)

Ludovic Rousseau
2016-04-08 20:50 GMT+02:00 Andrey R <[hidden email]>:
Hi. 

Hello,
 
Valgrind detected usage of uninitialized memory in SCardConnect:

==19635== Memcheck, a memory error detector
==19635== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==19635== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==19635== Command: /usr/rtests/bin/Pkcs11UnitTest.X64 pkcs11_common
==19635==
Running pkcs11_common
pkcs11_common::testGetInfo==19635== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==19635== at 0x605A1F7: send (send.c:32)
==19635== by 0xBC47CE6: ??? (in /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0)
==19635== by 0xBC47E22: ??? (in /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0)
==19635== by 0xBC43BBE: SCardConnect (in /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0)
...

connect_struct.szReader involved. Patch for resolving the problem:
root@test-x64-ub13:/tmp# diff -u pcsc-lite-1.8.16/src/winscard_clnt.c{,.patched}
--- pcsc-lite-1.8.16/src/winscard_clnt.c 2016-03-12 23:03:09.000000000 +0400
+++ pcsc-lite-1.8.16/src/winscard_clnt.c.patched 2016-04-07 16:20:28.193294111 +0400
@@ -764,7 +764,7 @@
LPDWORD pdwActiveProtocol)
{
LONG rv;
- struct connect_struct scConnectStruct;
+ struct connect_struct scConnectStruct = { 0 };
SCONTEXTMAP * currentContextMap;

PROFILE_START



I modified your patch since it generated a compiler warning:
winscard_clnt.c:767:46: warning: missing field 'szReader' initializer
      [-Wmissing-field-initializers]
        struct connect_struct scConnectStruct = { 0 };
                                                    ^

Thanks.

--
 Dr. Ludovic Rousseau

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle