Re: [PATCH] Implement safe_strncpy() as strlcpy() and use it more. [Take 2]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

* Peter Eriksen [06-06-11 14:03:28 +0200] wrote:

-char *safe_strncpy(char *dest, const char *src, size_t n)
+size_t safe_strncpy(char *dest, const char *src, size_t size)
{
-	strncpy(dest, src, n);
-	dest[n - 1] = '\0';
+	size_t ret = strlen(src);

At least FreeBSD's strlen() requires a non-NULL argument, i.e. with src==NULL, this will segfault.

If you can ensure that src!=NULL, then it's okay, but the safe_ prefix implies something different.

  bye, Rocco
--
:wq!
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]