netdev
[Top] [All Lists]

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

To: felipe_alfaro@xxxxxxxxxxxxx
Subject: Re: [PATCH 2.6]: IPv6: strcpy -> strlcpy
From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@xxxxxxxxxxxxxx>
Date: Fri, 28 Nov 2003 09:26:42 +0900 (JST)
Cc: rmk+lkml@xxxxxxxxxxxxxxxx, davem@xxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxx, yoshfuji@xxxxxxxxxxxxxx
In-reply-to: <20031128.092326.39861126.yoshfuji@linux-ipv6.org>
Organization: USAGI Project
References: <20031127221928.F25015@flint.arm.linux.org.uk> <1069974209.5349.7.camel@teapot.felipe-alfaro.com> <20031128.092326.39861126.yoshfuji@linux-ipv6.org>
Sender: netdev-bounce@xxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>