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:26:39
Also in: lkml

Possibly related (same subject, not in this thread)

In article [ref] (at Fri, 28 Nov 2003 09:23:26 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 [off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help