Re: [PATCH 2.6]: IPv6: strcpy -> strlcpy
From: YOSHIFUJI Hideaki / 吉藤英明
Date: Thu Nov 27 2003 - 19:30:06 EST
In article <1069974209.5349.7.camel@xxxxxxxxxxxxxxxxxxxxxxxx> (at Fri, 28 Nov 2003 00:03:29 +0100), Felipe Alfaro Solana <felipe_alfaro@xxxxxxxxxxxxx> says:
> So, as I see:
>
> 1. We should fix strncpy()
> 2. I should replace strlcpy() with strncpy() in my patches.
I think it is NOT correct.
It SEEMS unsafe to use strncpy() even if it terminated
string correctly.
So, I'd suggest to replace
strlcpy(dst, src, len);
with
1) strlcpy0(dst, src, len);
where strlcpy0() is provided in my previous mail,
or with
2) memset(dst, 0, len);
strncpy(dst, src, len);
(or say, strncpy0())
or, with
3) if (len)
strncpy(dst, src, len - 1);
dst[len] = 0;
(or, say, strncpy0()).
--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/