[Pcsclite-git-commit] [PCSC] 01/02: pcsc_stringify_error(): use Thread-local storage
Ludovic Rousseau
rousseau at moszumanska.debian.org
Wed Jan 18 16:12:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
rousseau pushed a commit to branch master
in repository PCSC.
commit eab1d67295e4e1d5c12bbca77bc57c50fd384a4e
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date: Wed Jan 18 16:58:29 2017 +0100
pcsc_stringify_error(): use Thread-local storage
" The pcsc_stringify_error() function in the PC/SC-Lite implementation
uses a statically allocated buffer. This means that the buffer may be
used simultaneously when the function is called from multiple threads
concurrently.
Therefore, the returned message may be spoiled, e.g.:
"Internal error.ul"
or
"Command cancell"
In the worst-case scenario, the application may read an unbounded
string (with the terminating null character missing). "
Thanks to Maksim Ivanov fro the bug report
"[Pcsclite-muscle] pcsc_stringify_error thread safety"
https://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20170116/000781.html
and Ivo Raisr (and Nikos Mavrogiannopoulos) for the solution
"[Pcsclite-muscle] pcsc_stringify_error thread safety"
https://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20170116/000782.html
---
src/error.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/error.c b/src/error.c
index 08db0ca..a261768 100644
--- a/src/error.c
+++ b/src/error.c
@@ -76,7 +76,9 @@ PCSC_API char* pcsc_stringify_error(const LONG pcscError)
*/
PCSC_API char* pcsc_stringify_error(const LONG pcscError)
{
- static char strError[75];
+ /* Use a Thread-local storage so that the returned buffer
+ * is thread safe */
+ __thread static char strError[75];
const char *msg = NULL;
switch (pcscError)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/PCSC.git
More information about the Pcsclite-cvs-commit
mailing list