lkml.org 
[lkml]   [2003]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2.6]: IPv6: strcpy -> strlcpy
From
In article <20031128.092326.39861126.yoshfuji@linux-ipv6.org> (at Fri, 28 Nov 2003 09:23:26 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org> says:

> 2) memset(dst, 0, len);
> strncpy(dst, src, len);

oops, this should be

memset(dst, 0, len);
if (len > 0)
strncpy(dst, src, len - 1);


> 3) if (len)
> strncpy(dst, src, len - 1);
> dst[len] = 0;
>
> (or, say, strncpy0()).

Note: in this case, we need to fix strncpy() first
to zero-out rest of destination buffer.

--yoshfuji
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.054 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site