diff --git a/src/core/debug.cpp b/src/core/debug.cpp index a8be328..7c285bb 100644 --- a/src/core/debug.cpp +++ b/src/core/debug.cpp @@ -63,7 +63,7 @@ cDebug::cDebug(const char* label) cDebug::cDebug(const cDebug &rhs) { - strlcpy(mLabel, rhs.mLabel, MAX_LABEL); + strncpy(mLabel, rhs.mLabel, MAX_LABEL); } cDebug::~cDebug() diff --git a/src/core/msystem.cpp b/src/core/msystem.cpp index 8aa12fa..f3dfba3 100644 --- a/src/core/msystem.cpp +++ b/src/core/msystem.cpp @@ -228,7 +228,7 @@ char *getenv(); /* get variable from environment */ size_t p_size = (strlen(str)+1)*sizeof(char); if ((p = (char*)malloc((unsigned)(p_size))) != NULL) - (void) strlcpy(p, str, p_size); + (void) strncpy(p, str, p_size); return(p); } #endif @@ -416,9 +416,9 @@ char *env; return(SE_NOMEM); } else{ - (void) strlcpy(p, env, p_size); - (void) strlcat(p, "=", p_size); - (void) strlcat(p, q, p_size); + (void) strncpy(p, env, p_size); + (void) strncat(p, "=", p_size); + (void) strncat(p, q, p_size); } } else if ((p = strdup(env)) == NULL){ diff --git a/src/core/unixfsservices.cpp b/src/core/unixfsservices.cpp index d5b87c0..4843059 100644 --- a/src/core/unixfsservices.cpp +++ b/src/core/unixfsservices.cpp @@ -264,7 +264,7 @@ TSTRING& cUnixFSServices::MakeTempFilename( TSTRING& strName ) const char szTemplate[iFSServices::TW_MAX_PATH]; int fd; - strlcpy( szTemplate, strName.c_str(), iFSServices::TW_MAX_PATH ); + strncpy( szTemplate, strName.c_str(), iFSServices::TW_MAX_PATH ); #ifdef HAVE_MKSTEMP // create temp filename and check to see if mkstemp failed @@ -605,7 +605,7 @@ bool cUnixFSServices::GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const void cUnixFSServices::ConvertModeToString( uint64 perm, TSTRING& tstrPerm ) const { TCHAR szPerm[11]; //10 permission bits plus the NULL - strlcpy( szPerm, _T("----------"), 11); + strncpy( szPerm, _T("----------"), 9); ASSERT( sizeof(unsigned short) <= sizeof(uint32) ); // We do this in case an "unsigned short" is ever larger than the diff --git a/src/fco/fconametbl.cpp b/src/fco/fconametbl.cpp index edc2c8f..a331533 100644 --- a/src/fco/fconametbl.cpp +++ b/src/fco/fconametbl.cpp @@ -112,7 +112,7 @@ void cFCONameTblNode::SetString(const TSTRING& newStr) size_t alloc_size = sizeof(TCHAR)*(newStr.length()+1); mpString = (TCHAR*)util_AllocMem(alloc_size); - strlcpy( mpString, newStr.c_str(), alloc_size ); + strncpy( mpString, newStr.c_str(), alloc_size ); // NOTE -- the lower case pointer is now invalid. } diff --git a/src/fco/signature.cpp b/src/fco/signature.cpp index 4f8dd1c..4278ed1 100644 --- a/src/fco/signature.cpp +++ b/src/fco/signature.cpp @@ -550,14 +550,14 @@ TSTRING cMD5Signature::AsStringHex() const TSTRING ret; TCHAR stringBuffer[128]; - TCHAR sigStringOut[128]; + TCHAR sigStringOut[129]; sigStringOut[0] = '\0'; uint8 *dbuf = (uint8 *)md5_digest; for(int i = 0; i < SIG_BYTE_SIZE; ++i) { snprintf(stringBuffer, 128, _T("%02lx"), (unsigned long)dbuf[i]); - strlcat(sigStringOut, stringBuffer, 128); + strncat(sigStringOut, stringBuffer, 128); } ret.append(sigStringOut); @@ -673,14 +673,14 @@ TSTRING cSHASignature::AsStringHex() const TSTRING ret; TCHAR stringBuffer[128]; - TCHAR sigStringOut[128]; + TCHAR sigStringOut[129]; sigStringOut[0] = '\0'; uint8 *dbuf = (uint8 *)sha_digest; for (int i=0; i < SIG_UINT32_SIZE*(int)sizeof(uint32); ++i) { snprintf(stringBuffer, 128, _T("%02x"), dbuf[i]); - strlcat(sigStringOut, stringBuffer, 128); + strncat(sigStringOut, stringBuffer, 128); } ret.append(sigStringOut); @@ -749,13 +749,13 @@ TSTRING cSHASignature::AsStringHex() const TSTRING ret; TCHAR stringBuffer[128]; - TCHAR sigStringOut[128]; + TCHAR sigStringOut[129]; sigStringOut[0] = '\0'; for (int i=0; i < SIG_UINT32_SIZE; ++i) { snprintf(stringBuffer, 128, _T("%08x"), mSHAInfo.digest[i]); - strlcat(sigStringOut, stringBuffer, 128); + strncat(sigStringOut, stringBuffer, 128); } ret.append(sigStringOut); @@ -851,13 +851,13 @@ TSTRING cHAVALSignature::AsStringHex() const TSTRING ret; TCHAR stringBuffer[128]; - TCHAR sigStringOut[128]; + TCHAR sigStringOut[129]; sigStringOut[0] = _T('\0'); for (int i=0; i < SIG_BYTE_SIZE; ++i) { snprintf(stringBuffer, 128, _T("%02x"), mSignature[i]); - strlcat(sigStringOut, stringBuffer, 128); + strncat(sigStringOut, stringBuffer, 128); } ret.append(sigStringOut); diff --git a/src/tripwire/smtpmailmessage.cpp b/src/tripwire/smtpmailmessage.cpp index 655e11f..9e63bc7 100644 --- a/src/tripwire/smtpmailmessage.cpp +++ b/src/tripwire/smtpmailmessage.cpp @@ -90,7 +90,7 @@ static int gethostname( char* name, int namelen ) if ( strlen( myname.nodename ) < (unsigned int)namelen ) { - strlcpy( name, myname.nodename, namelen ); + strncpy( name, myname.nodename, namelen ); return 0; } else @@ -100,7 +100,7 @@ static int gethostname( char* name, int namelen ) // equivalent of SOCKET_ERROR } #else - strlcpy(name, "localhost", namelen); + strncpy(name, "localhost", namelen); #endif } diff --git a/src/twparser/yyparse.cpp b/src/twparser/yyparse.cpp index 806f7a7..9deb903 100644 --- a/src/twparser/yyparse.cpp +++ b/src/twparser/yyparse.cpp @@ -1393,7 +1393,7 @@ yy_parse::yyExpandName(int num, int isrule, char * buf, int len) for (endp = buf + len - 8; *s; s++) { if (buf >= endp) { /* too large: return 0 */ - full: (void) strlcpy(buf, " ...\n", len); + full: (void) strncpy(buf, " ...\n", len); return 0; } else if (*s == '%') { /* nonterminal */ type = 0; @@ -1423,7 +1423,7 @@ yy_parse::yyExpandName(int num, int isrule, char * buf, int len) if ((i = strlen(cp)) + buf > endp) goto full; - (void) strlcpy(buf, cp, len); + (void) strncpy(buf, cp, len); buf += i; } else *buf++ = *s;