- fixed some strlcpy bugs
This commit is contained in:
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 */
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user