Thread (7 messages) 7 messages, 4 authors, 2003-11-28

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

From: YOSHIFUJI Hideaki / 吉藤英明 <hidden>
Date: 2003-11-28 00:23:23
Also in: lkml

Possibly related (same subject, not in this thread)

In article [ref] (at Fri, 28 Nov 2003 00:03:29 +0100), Felipe Alfaro Solana [off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help