- fixed some strlcpy bugs

This commit is contained in:
zolliker
2010-04-15 09:40:27 +00:00
parent ce0e418326
commit 5ffe4f3905
3 changed files with 2 additions and 16 deletions

View File

@ -1064,6 +1064,7 @@ static hdbCallbackReturn MemGenSetCallback(pHdb node, void *userData,
memcpy(userData, &mm->v->v.doubleValue, sizeof(double));
break;
case HIPTEXT:
/* the use of strlcpy is probably buggy here (M.Z. 15.4.2010) */
strlcpy((char *) userData, (const char *) mm->v->v.text,
node->value.arrayLength);
break;

View File

@ -378,7 +378,7 @@ static int SinfoxReadKey(pSinfox pSin, SicsInterp * pSics,
continue;
iLen = pPos - pBuf;
strlcpy(pName, pBuf, iLen);
strncpy(pName, pBuf, iLen); /* strlcpy is wrong here */
pName[iLen] = '\0';
strcpy(pValue, (pPos + 1));
RemoveWhiteSpace(pName);

View File

@ -170,11 +170,6 @@ int StringDictGet(pStringDict self, char *name, char *pResult, int iLen)
return strlen(sVal.value) + 1; /* for \0 */
} else {
strlcpy(pResult, sVal.value, iLen);
/* strncpy is not guaranteed to be '\0' terminated */
if (iLen > 0 && pResult[iLen - 1] != '\0') {
/* overflow */
pResult[iLen - 1] = '\0';
}
return 1;
}
}
@ -261,11 +256,6 @@ const char *StringDictGetNext(pStringDict self, char *pValue, int iValLen)
} else {
LLDnodeDataTo(self->iList, &sVal);
strlcpy(pValue, sVal.value, iValLen);
/* strncpy is not guaranteed to be '\0' terminated */
if (iValLen > 0 && pValue[iValLen-1] != '\0') {
/* overflow */
pValue[iValLen-1] = '\0';
}
return sVal.name;
}
@ -278,11 +268,6 @@ const char *StringDictGetNext(pStringDict self, char *pValue, int iValLen)
self->iTraverse = 1;
LLDnodeDataTo(self->iList, &sVal);
strlcpy(pValue, sVal.value, iValLen);
/* strncpy is not guaranteed to be '\0' terminated */
if (iValLen > 0 && pValue[iValLen-1] != '\0') {
/* overflow */
pValue[iValLen-1] = '\0';
}
return sVal.name;
}
}