[Pcsclite-cvs-commit] CVS PCSC/src
CVS User rousseau
ludovic.rousseau@free.fr
Tue, 07 Sep 2004 02:40:45 -0600
Update of /cvsroot/pcsclite/PCSC/src
In directory haydn:/tmp/cvs-serv556/src
Modified Files:
debuglog.c
Log Message:
use strlcpy/strlcat instead of strncpy/strncat
--- /cvsroot/pcsclite/PCSC/src/debuglog.c 2004/08/06 12:12:20 1.25
+++ /cvsroot/pcsclite/PCSC/src/debuglog.c 2004/09/07 08:40:44 1.26
@@ -7,7 +7,7 @@
* David Corcoran <corcoran@linuxnet.com>
* Ludovic Rousseau <ludovic.rousseau@free.fr>
*
- * $Id: debuglog.c,v 1.25 2004/08/06 12:12:20 rousseau Exp $
+ * $Id: debuglog.c,v 1.26 2004/09/07 08:40:44 rousseau Exp $
*/
#include "config.h"
@@ -25,6 +25,7 @@
#include "pcsclite.h"
#include "debuglog.h"
#include "sys_generic.h"
+#include "strlcpycat.h"
/* Max string size when dumping a 256 bytes longs APDU
* Should be bigger than 256*3+30 */
@@ -95,7 +96,7 @@
debug_buf_end = DebugBuffer + DEBUG_BUF_SIZE - 5;
- strncpy(DebugBuffer, msg, sizeof(DebugBuffer) - 1);
+ strlcpy(DebugBuffer, msg, sizeof(DebugBuffer));
c = DebugBuffer + strlen(DebugBuffer);
for (i = 0; (i < len) && (c < debug_buf_end); ++i)
@@ -160,7 +161,7 @@
text[0] = '\0';
if (debug_category & DEBUG_CATEGORY_APDU)
- strncat(text, " APDU", DEBUG_INFO_LENGTH-1-strlen(text));
+ strlcat(text, " APDU", sizeof(text));
DebugLogB("Debug options:%s", text);
@@ -186,115 +187,115 @@
switch (pcscError)
{
case SCARD_S_SUCCESS:
- strncpy(strError, "Command successful.", sizeof(strError)-1);
+ strlcpy(strError, "Command successful.", sizeof(strError));
break;
case SCARD_E_CANCELLED:
- strncpy(strError, "Command cancelled.", sizeof(strError)-1);
+ strlcpy(strError, "Command cancelled.", sizeof(strError));
break;
case SCARD_E_CANT_DISPOSE:
- strncpy(strError, "Cannot dispose handle.", sizeof(strError)-1);
+ strlcpy(strError, "Cannot dispose handle.", sizeof(strError));
break;
case SCARD_E_INSUFFICIENT_BUFFER:
- strncpy(strError, "Insufficient buffer.", sizeof(strError)-1);
+ strlcpy(strError, "Insufficient buffer.", sizeof(strError));
break;
case SCARD_E_INVALID_ATR:
- strncpy(strError, "Invalid ATR.", sizeof(strError)-1);
+ strlcpy(strError, "Invalid ATR.", sizeof(strError));
break;
case SCARD_E_INVALID_HANDLE:
- strncpy(strError, "Invalid handle.", sizeof(strError)-1);
+ strlcpy(strError, "Invalid handle.", sizeof(strError));
break;
case SCARD_E_INVALID_PARAMETER:
- strncpy(strError, "Invalid parameter given.", sizeof(strError)-1);
+ strlcpy(strError, "Invalid parameter given.", sizeof(strError));
break;
case SCARD_E_INVALID_TARGET:
- strncpy(strError, "Invalid target given.", sizeof(strError)-1);
+ strlcpy(strError, "Invalid target given.", sizeof(strError));
break;
case SCARD_E_INVALID_VALUE:
- strncpy(strError, "Invalid value given.", sizeof(strError)-1);
+ strlcpy(strError, "Invalid value given.", sizeof(strError));
break;
case SCARD_E_NO_MEMORY:
- strncpy(strError, "Not enough memory.", sizeof(strError)-1);
+ strlcpy(strError, "Not enough memory.", sizeof(strError));
break;
case SCARD_F_COMM_ERROR:
- strncpy(strError, "RPC transport error.", sizeof(strError)-1);
+ strlcpy(strError, "RPC transport error.", sizeof(strError));
break;
case SCARD_F_INTERNAL_ERROR:
- strncpy(strError, "Unknown internal error.", sizeof(strError)-1);
+ strlcpy(strError, "Unknown internal error.", sizeof(strError));
break;
case SCARD_F_UNKNOWN_ERROR:
- strncpy(strError, "Unknown internal error.", sizeof(strError)-1);
+ strlcpy(strError, "Unknown internal error.", sizeof(strError));
break;
case SCARD_F_WAITED_TOO_LONG:
- strncpy(strError, "Waited too long.", sizeof(strError)-1);
+ strlcpy(strError, "Waited too long.", sizeof(strError));
break;
case SCARD_E_UNKNOWN_READER:
- strncpy(strError, "Unknown reader specified.", sizeof(strError)-1);
+ strlcpy(strError, "Unknown reader specified.", sizeof(strError));
break;
case SCARD_E_TIMEOUT:
- strncpy(strError, "Command timeout.", sizeof(strError)-1);
+ strlcpy(strError, "Command timeout.", sizeof(strError));
break;
case SCARD_E_SHARING_VIOLATION:
- strncpy(strError, "Sharing violation.", sizeof(strError)-1);
+ strlcpy(strError, "Sharing violation.", sizeof(strError));
break;
case SCARD_E_NO_SMARTCARD:
- strncpy(strError, "No smart card inserted.", sizeof(strError)-1);
+ strlcpy(strError, "No smart card inserted.", sizeof(strError));
break;
case SCARD_E_UNKNOWN_CARD:
- strncpy(strError, "Unknown card.", sizeof(strError)-1);
+ strlcpy(strError, "Unknown card.", sizeof(strError));
break;
case SCARD_E_PROTO_MISMATCH:
- strncpy(strError, "Card protocol mismatch.", sizeof(strError)-1);
+ strlcpy(strError, "Card protocol mismatch.", sizeof(strError));
break;
case SCARD_E_NOT_READY:
- strncpy(strError, "Subsystem not ready.", sizeof(strError)-1);
+ strlcpy(strError, "Subsystem not ready.", sizeof(strError));
break;
case SCARD_E_SYSTEM_CANCELLED:
- strncpy(strError, "System cancelled.", sizeof(strError)-1);
+ strlcpy(strError, "System cancelled.", sizeof(strError));
break;
case SCARD_E_NOT_TRANSACTED:
- strncpy(strError, "Transaction failed.", sizeof(strError)-1);
+ strlcpy(strError, "Transaction failed.", sizeof(strError));
break;
case SCARD_E_READER_UNAVAILABLE:
- strncpy(strError, "Reader/s is unavailable.", sizeof(strError)-1);
+ strlcpy(strError, "Reader/s is unavailable.", sizeof(strError));
break;
case SCARD_W_UNSUPPORTED_CARD:
- strncpy(strError, "Card is not supported.", sizeof(strError)-1);
+ strlcpy(strError, "Card is not supported.", sizeof(strError));
break;
case SCARD_W_UNRESPONSIVE_CARD:
- strncpy(strError, "Card is unresponsive.", sizeof(strError)-1);
+ strlcpy(strError, "Card is unresponsive.", sizeof(strError));
break;
case SCARD_W_UNPOWERED_CARD:
- strncpy(strError, "Card is unpowered.", sizeof(strError)-1);
+ strlcpy(strError, "Card is unpowered.", sizeof(strError));
break;
case SCARD_W_RESET_CARD:
- strncpy(strError, "Card was reset.", sizeof(strError)-1);
+ strlcpy(strError, "Card was reset.", sizeof(strError));
break;
case SCARD_W_REMOVED_CARD:
- strncpy(strError, "Card was removed.", sizeof(strError)-1);
+ strlcpy(strError, "Card was removed.", sizeof(strError));
break;
case SCARD_W_INSERTED_CARD:
- strncpy(strError, "Card was inserted.", sizeof(strError)-1);
+ strlcpy(strError, "Card was inserted.", sizeof(strError));
break;
case SCARD_E_UNSUPPORTED_FEATURE:
- strncpy(strError, "Feature not supported.", sizeof(strError)-1);
+ strlcpy(strError, "Feature not supported.", sizeof(strError));
break;
case SCARD_E_PCI_TOO_SMALL:
- strncpy(strError, "PCI struct too small.", sizeof(strError)-1);
+ strlcpy(strError, "PCI struct too small.", sizeof(strError));
break;
case SCARD_E_READER_UNSUPPORTED:
- strncpy(strError, "Reader is unsupported.", sizeof(strError)-1);
+ strlcpy(strError, "Reader is unsupported.", sizeof(strError));
break;
case SCARD_E_DUPLICATE_READER:
- strncpy(strError, "Reader already exists.", sizeof(strError)-1);
+ strlcpy(strError, "Reader already exists.", sizeof(strError));
break;
case SCARD_E_CARD_UNSUPPORTED:
- strncpy(strError, "Card is unsupported.", sizeof(strError)-1);
+ strlcpy(strError, "Card is unsupported.", sizeof(strError));
break;
case SCARD_E_NO_SERVICE:
- strncpy(strError, "Service not available.", sizeof(strError)-1);
+ strlcpy(strError, "Service not available.", sizeof(strError));
break;
case SCARD_E_SERVICE_STOPPED:
- strncpy(strError, "Service was stopped.", sizeof(strError)-1);
+ strlcpy(strError, "Service was stopped.", sizeof(strError));
break;
default:
snprintf(strError, sizeof(strError)-1, "Unkown error: 0x%08lX",