- fixed some strlcpy bugs
This commit is contained in:
@ -1064,6 +1064,7 @@ static hdbCallbackReturn MemGenSetCallback(pHdb node, void *userData,
|
|||||||
memcpy(userData, &mm->v->v.doubleValue, sizeof(double));
|
memcpy(userData, &mm->v->v.doubleValue, sizeof(double));
|
||||||
break;
|
break;
|
||||||
case HIPTEXT:
|
case HIPTEXT:
|
||||||
|
/* the use of strlcpy is probably buggy here (M.Z. 15.4.2010) */
|
||||||
strlcpy((char *) userData, (const char *) mm->v->v.text,
|
strlcpy((char *) userData, (const char *) mm->v->v.text,
|
||||||
node->value.arrayLength);
|
node->value.arrayLength);
|
||||||
break;
|
break;
|
||||||
|
2
sinfox.c
2
sinfox.c
@ -378,7 +378,7 @@ static int SinfoxReadKey(pSinfox pSin, SicsInterp * pSics,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
iLen = pPos - pBuf;
|
iLen = pPos - pBuf;
|
||||||
strlcpy(pName, pBuf, iLen);
|
strncpy(pName, pBuf, iLen); /* strlcpy is wrong here */
|
||||||
pName[iLen] = '\0';
|
pName[iLen] = '\0';
|
||||||
strcpy(pValue, (pPos + 1));
|
strcpy(pValue, (pPos + 1));
|
||||||
RemoveWhiteSpace(pName);
|
RemoveWhiteSpace(pName);
|
||||||
|
15
stringdict.c
15
stringdict.c
@ -170,11 +170,6 @@ int StringDictGet(pStringDict self, char *name, char *pResult, int iLen)
|
|||||||
return strlen(sVal.value) + 1; /* for \0 */
|
return strlen(sVal.value) + 1; /* for \0 */
|
||||||
} else {
|
} else {
|
||||||
strlcpy(pResult, sVal.value, iLen);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,11 +256,6 @@ const char *StringDictGetNext(pStringDict self, char *pValue, int iValLen)
|
|||||||
} else {
|
} else {
|
||||||
LLDnodeDataTo(self->iList, &sVal);
|
LLDnodeDataTo(self->iList, &sVal);
|
||||||
strlcpy(pValue, sVal.value, iValLen);
|
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;
|
return sVal.name;
|
||||||
}
|
}
|
||||||
@ -278,11 +268,6 @@ const char *StringDictGetNext(pStringDict self, char *pValue, int iValLen)
|
|||||||
self->iTraverse = 1;
|
self->iTraverse = 1;
|
||||||
LLDnodeDataTo(self->iList, &sVal);
|
LLDnodeDataTo(self->iList, &sVal);
|
||||||
strlcpy(pValue, sVal.value, iValLen);
|
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;
|
return sVal.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user