Re: [PATCH 2.6]: IPv6: strcpy -> strlcpy

From: YOSHIFUJI Hideaki / 吉藤英明
Date: Thu Nov 27 2003 - 19:30:06 EST


In article <20031128.092326.39861126.yoshfuji@xxxxxxxxxxxxxx> (at Fri, 28 Nov 2003 09:23:26 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/