From 6ce12ed5d973f241f18d8db1891cbba483d81d25 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:54:32 +0000 Subject: Utilisateur : Fcolin Date : 16/11/05 Heure : 9:54 Archivé dans $/Bus/Ivy Commentaire: 64 bits ports (vss 11) --- Bus/Ivy/DataTypes.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'Bus/Ivy') diff --git a/Bus/Ivy/DataTypes.h b/Bus/Ivy/DataTypes.h index 190a7a6..280c2de 100644 --- a/Bus/Ivy/DataTypes.h +++ b/Bus/Ivy/DataTypes.h @@ -10,7 +10,7 @@ #endif #include - +#include namespace ivy { @@ -39,17 +39,19 @@ public: { if ( ptr ) delete [] ptr; ptr = allocBuffer( len ); - strncpy( ptr, s, len ); + strncpy_s( ptr, len + 1, s, len ); } void erase(size_t start=0, size_t len = npos) { char *newptr; size_t real_len; + size_t buf_size; real_len = len == npos ? size - start : len; if ( real_len > size ) real_len = size; - newptr = allocBuffer( size - real_len ); - strncpy( newptr, ptr , start ); - strncpy( &newptr[start], &ptr[start+real_len], size - start ); + buf_size = size - real_len; + newptr = allocBuffer( buf_size ); + strncpy_s( newptr, buf_size +1, ptr , start ); + strncpy_s( &newptr[start], buf_size +1 - start, &ptr[start+real_len], size - start ); delete ptr; ptr = newptr; } @@ -61,10 +63,11 @@ public: { char *newptr; if ( len == npos ) len = strlen(s) ; - newptr = allocBuffer( size + len ); - strncpy( newptr , ptr, index ); - strncpy( newptr+index , s, len ) ; - strncpy( newptr+index+len , &ptr[index], size - (index+len) ) ; + size_t buf_len = size + len; + newptr = allocBuffer( buf_len ); + strncpy_s( newptr , buf_len +1, ptr, index ); + strncpy_s( newptr+index, buf_len + 1 - index, s, len ) ; + strncpy_s( newptr+index+len, buf_len + 1 - index -len, &ptr[index], size - (index+len) ) ; delete ptr; ptr = newptr; } -- cgit v1.1