[Pcsclite-cvs-commit] r5836 - /trunk/Drivers/ccid/src/debug.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Wed Jul 6 09:40:11 UTC 2011
Author: rousseau
Date: Wed Jul 6 09:40:10 2011
New Revision: 5836
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5836
Log:
log_xxd(): use safer snprintf() instead of sprintf()
coverity: Event secure_coding: [VERY RISKY]. Using "sprintf" can cause a
buffer overflow when done incorrectly. Because sprintf() assumes an
arbitrarily long string, callers must be careful not to overflow the
actual space of the destination. Use snprintf() instead, or correct
precision specifiers.
Modified:
trunk/Drivers/ccid/src/debug.c
Modified: trunk/Drivers/ccid/src/debug.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/debug.c?rev=5836&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/debug.c (original)
+++ trunk/Drivers/ccid/src/debug.c Wed Jul 6 09:40:10 2011
@@ -65,7 +65,8 @@
for (i = 0; (i < len) && (c < debug_buf_end); ++i)
{
- (void)sprintf(c, "%02X ", (unsigned char)buffer[i]);
+ /* 2 hex characters, 1 space, 1 NUL : total 4 characters */
+ (void)snprintf(c, 4, "%02X ", (unsigned char)buffer[i]);
c += strlen(c);
}
More information about the Pcsclite-cvs-commit
mailing list