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 <1069974209.5349.7.camel@teapot.felipe-alfaro.com> (at Fri, 28 Nov 2003 00:03:29 +0100), Felipe Alfaro Solana <felipe_alfaro@linuxmail.org> 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@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:1.804 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site