strlcat() isn't supposed to access *dst past dst_sz

Try not to do that on platforms where we can avoid it.
This commit is contained in:
Asanka Herath
2010-08-24 00:04:17 -04:00
committed by Asanka C. Herath
parent 7e3bd7f9aa
commit d4fc674024

View File

@@ -39,9 +39,16 @@
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
strlcat (char *dst, const char *src, size_t dst_sz)
{
size_t len = strlen(dst);
size_t len;
#if defined(_MSC_VER) && _MSC_VER >= 1400
len = strnlen_s(dst, dst_sz);
#elif defined(HAVE_STRNLEN)
len = strnlen(dst, dst_sz);
#else
len = strlen(dst);
#endif
if (dst_sz < len)
if (dst_sz <= len)
/* the total size of dst is less than the string it contains;
this could be considered bad input, but we might as well
handle it */