- fixed some potential bugs with strlcpy

This commit is contained in:
zolliker
2010-04-15 11:24:27 +00:00
parent ffa378b60d
commit 4a5691503d
3 changed files with 4 additions and 4 deletions

View File

@ -108,12 +108,12 @@ static int sinqHttpCheckResponse(pSinqHttp self)
} }
if (strstr(pPtr, "ERROR") != NULL) { if (strstr(pPtr, "ERROR") != NULL) {
memset(self->hmError, 0, 512 * sizeof(char)); memset(self->hmError, 0, 512 * sizeof(char));
strlcpy(self->hmError, pPtr, len); strlcpy(self->hmError, pPtr, sizeof(self->hmError));
self->errorCode = HTTPERROR; self->errorCode = HTTPERROR;
return 0; return 0;
} else if (strstr(pPtr, "Authentication Error") != NULL) { } else if (strstr(pPtr, "Authentication Error") != NULL) {
memset(self->hmError, 0, 512 * sizeof(char)); memset(self->hmError, 0, 512 * sizeof(char));
strlcpy(self->hmError, pPtr, len); strlcpy(self->hmError, pPtr, sizeof(self->hmError));
self->errorCode = BADAUTH; self->errorCode = BADAUTH;
return 0; return 0;
} }

2
sps.c
View File

@ -450,7 +450,7 @@ int SPSGetADC(pSPS self, int iWhich, int *iValue)
pPtr++; pPtr++;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
pPtr++; /* skip whitespace */ pPtr++; /* skip whitespace */
strlcpy(pNum, pPtr, 5); strncpy(pNum, pPtr, 5); /* strlcpy probably wrong here */
pNum[5] = '\0'; pNum[5] = '\0';
pPtr += 5; pPtr += 5;
iADC[i] = atoi(pNum); iADC[i] = atoi(pNum);

View File

@ -334,7 +334,7 @@ int DornierSend(void **pData, char *pCommand, char *pReply, int iRepLen)
if (*pPtr == '\0') { /* no command */ if (*pPtr == '\0') { /* no command */
return NOCOMMAND; return NOCOMMAND;
} }
strlcpy(pOldCom, pPtr, 3); strncpy(pOldCom, pPtr, 3); /* strlcpy probably wrong here */
iRet = SerialWriteRead(pData, pCommand, pReply, iRepLen); iRet = SerialWriteRead(pData, pCommand, pReply, iRepLen);
/* /*