Ok, actually don't use strl* string functions since they're a BSD-ism & Linux doesn't have them.

This commit is contained in:
Brian Cox 2017-03-25 16:02:51 -07:00
parent 7ce1df0a04
commit e04b97132b
7 changed files with 20 additions and 20 deletions

View File

@ -63,7 +63,7 @@ cDebug::cDebug(const char* label)
cDebug::cDebug(const cDebug &rhs) cDebug::cDebug(const cDebug &rhs)
{ {
strlcpy(mLabel, rhs.mLabel, MAX_LABEL); strncpy(mLabel, rhs.mLabel, MAX_LABEL);
} }
cDebug::~cDebug() cDebug::~cDebug()

View File

@ -228,7 +228,7 @@ char *getenv(); /* get variable from environment */
size_t p_size = (strlen(str)+1)*sizeof(char); size_t p_size = (strlen(str)+1)*sizeof(char);
if ((p = (char*)malloc((unsigned)(p_size))) if ((p = (char*)malloc((unsigned)(p_size)))
!= NULL) != NULL)
(void) strlcpy(p, str, p_size); (void) strncpy(p, str, p_size);
return(p); return(p);
} }
#endif #endif
@ -416,9 +416,9 @@ char *env;
return(SE_NOMEM); return(SE_NOMEM);
} }
else{ else{
(void) strlcpy(p, env, p_size); (void) strncpy(p, env, p_size);
(void) strlcat(p, "=", p_size); (void) strncat(p, "=", p_size);
(void) strlcat(p, q, p_size); (void) strncat(p, q, p_size);
} }
} }
else if ((p = strdup(env)) == NULL){ else if ((p = strdup(env)) == NULL){

View File

@ -264,7 +264,7 @@ TSTRING& cUnixFSServices::MakeTempFilename( TSTRING& strName ) const
char szTemplate[iFSServices::TW_MAX_PATH]; char szTemplate[iFSServices::TW_MAX_PATH];
int fd; int fd;
strlcpy( szTemplate, strName.c_str(), iFSServices::TW_MAX_PATH ); strncpy( szTemplate, strName.c_str(), iFSServices::TW_MAX_PATH );
#ifdef HAVE_MKSTEMP #ifdef HAVE_MKSTEMP
// create temp filename and check to see if mkstemp failed // 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 void cUnixFSServices::ConvertModeToString( uint64 perm, TSTRING& tstrPerm ) const
{ {
TCHAR szPerm[11]; //10 permission bits plus the NULL TCHAR szPerm[11]; //10 permission bits plus the NULL
strlcpy( szPerm, _T("----------"), 11); strncpy( szPerm, _T("----------"), 9);
ASSERT( sizeof(unsigned short) <= sizeof(uint32) ); ASSERT( sizeof(unsigned short) <= sizeof(uint32) );
// We do this in case an "unsigned short" is ever larger than the // We do this in case an "unsigned short" is ever larger than the

View File

@ -112,7 +112,7 @@ void cFCONameTblNode::SetString(const TSTRING& newStr)
size_t alloc_size = sizeof(TCHAR)*(newStr.length()+1); size_t alloc_size = sizeof(TCHAR)*(newStr.length()+1);
mpString = (TCHAR*)util_AllocMem(alloc_size); 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. // NOTE -- the lower case pointer is now invalid.
} }

View File

@ -550,14 +550,14 @@ TSTRING cMD5Signature::AsStringHex() const
TSTRING ret; TSTRING ret;
TCHAR stringBuffer[128]; TCHAR stringBuffer[128];
TCHAR sigStringOut[128]; TCHAR sigStringOut[129];
sigStringOut[0] = '\0'; sigStringOut[0] = '\0';
uint8 *dbuf = (uint8 *)md5_digest; uint8 *dbuf = (uint8 *)md5_digest;
for(int i = 0; i < SIG_BYTE_SIZE; ++i) for(int i = 0; i < SIG_BYTE_SIZE; ++i)
{ {
snprintf(stringBuffer, 128, _T("%02lx"), (unsigned long)dbuf[i]); snprintf(stringBuffer, 128, _T("%02lx"), (unsigned long)dbuf[i]);
strlcat(sigStringOut, stringBuffer, 128); strncat(sigStringOut, stringBuffer, 128);
} }
ret.append(sigStringOut); ret.append(sigStringOut);
@ -673,14 +673,14 @@ TSTRING cSHASignature::AsStringHex() const
TSTRING ret; TSTRING ret;
TCHAR stringBuffer[128]; TCHAR stringBuffer[128];
TCHAR sigStringOut[128]; TCHAR sigStringOut[129];
sigStringOut[0] = '\0'; sigStringOut[0] = '\0';
uint8 *dbuf = (uint8 *)sha_digest; uint8 *dbuf = (uint8 *)sha_digest;
for (int i=0; i < SIG_UINT32_SIZE*(int)sizeof(uint32); ++i) for (int i=0; i < SIG_UINT32_SIZE*(int)sizeof(uint32); ++i)
{ {
snprintf(stringBuffer, 128, _T("%02x"), dbuf[i]); snprintf(stringBuffer, 128, _T("%02x"), dbuf[i]);
strlcat(sigStringOut, stringBuffer, 128); strncat(sigStringOut, stringBuffer, 128);
} }
ret.append(sigStringOut); ret.append(sigStringOut);
@ -749,13 +749,13 @@ TSTRING cSHASignature::AsStringHex() const
TSTRING ret; TSTRING ret;
TCHAR stringBuffer[128]; TCHAR stringBuffer[128];
TCHAR sigStringOut[128]; TCHAR sigStringOut[129];
sigStringOut[0] = '\0'; sigStringOut[0] = '\0';
for (int i=0; i < SIG_UINT32_SIZE; ++i) for (int i=0; i < SIG_UINT32_SIZE; ++i)
{ {
snprintf(stringBuffer, 128, _T("%08x"), mSHAInfo.digest[i]); snprintf(stringBuffer, 128, _T("%08x"), mSHAInfo.digest[i]);
strlcat(sigStringOut, stringBuffer, 128); strncat(sigStringOut, stringBuffer, 128);
} }
ret.append(sigStringOut); ret.append(sigStringOut);
@ -851,13 +851,13 @@ TSTRING cHAVALSignature::AsStringHex() const
TSTRING ret; TSTRING ret;
TCHAR stringBuffer[128]; TCHAR stringBuffer[128];
TCHAR sigStringOut[128]; TCHAR sigStringOut[129];
sigStringOut[0] = _T('\0'); sigStringOut[0] = _T('\0');
for (int i=0; i < SIG_BYTE_SIZE; ++i) for (int i=0; i < SIG_BYTE_SIZE; ++i)
{ {
snprintf(stringBuffer, 128, _T("%02x"), mSignature[i]); snprintf(stringBuffer, 128, _T("%02x"), mSignature[i]);
strlcat(sigStringOut, stringBuffer, 128); strncat(sigStringOut, stringBuffer, 128);
} }
ret.append(sigStringOut); ret.append(sigStringOut);

View File

@ -90,7 +90,7 @@ static int gethostname( char* name, int namelen )
if ( strlen( myname.nodename ) < (unsigned int)namelen ) if ( strlen( myname.nodename ) < (unsigned int)namelen )
{ {
strlcpy( name, myname.nodename, namelen ); strncpy( name, myname.nodename, namelen );
return 0; return 0;
} }
else else
@ -100,7 +100,7 @@ static int gethostname( char* name, int namelen )
// equivalent of SOCKET_ERROR // equivalent of SOCKET_ERROR
} }
#else #else
strlcpy(name, "localhost", namelen); strncpy(name, "localhost", namelen);
#endif #endif
} }

View File

@ -1393,7 +1393,7 @@ yy_parse::yyExpandName(int num, int isrule, char * buf, int len)
for (endp = buf + len - 8; *s; s++) { for (endp = buf + len - 8; *s; s++) {
if (buf >= endp) { /* too large: return 0 */ if (buf >= endp) { /* too large: return 0 */
full: (void) strlcpy(buf, " ...\n", len); full: (void) strncpy(buf, " ...\n", len);
return 0; return 0;
} else if (*s == '%') { /* nonterminal */ } else if (*s == '%') { /* nonterminal */
type = 0; type = 0;
@ -1423,7 +1423,7 @@ yy_parse::yyExpandName(int num, int isrule, char * buf, int len)
if ((i = strlen(cp)) + buf > endp) if ((i = strlen(cp)) + buf > endp)
goto full; goto full;
(void) strlcpy(buf, cp, len); (void) strncpy(buf, cp, len);
buf += i; buf += i;
} else } else
*buf++ = *s; *buf++ = *s;