> +size_t strlcat(char *dest, const char *src, size_t bufsize)
> +{
> + size_t len1 = strlen(dest);
> + size_t len2 = strlen(src);
> + size_t ret = len1 + len2;
> +
> + if (len1+len2 >= bufsize)
> + len2 = bufsize - (len1+1);
> + if (len2 > 0) {
> + memcpy(dest+len1, src, len2);
> + dest[len1+len2] = '\0';
> + }
> + return ret;
> +}
> +#endif
Your strlcat doesn't take into consideration that a zero bufsize could
mean that dest is not NUL-terminated, in which case strlen(dest) could
blow up in your face. Since strlcpy can handle zero bufsize, strlcat
should be able to handle being called just after strlcpy being called
with zero bufsize (see my patch).
I personally am not concerned either way, but it is definitely worth
noting.
-- Debian - http://www.debian.org/ Linux 1394 - http://www.linux1394.org/ Subversion - http://subversion.tigris.org/ Deqo - http://www.deqo.com/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/