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:23:26 +0900 (JST)
Cc: rmk+lkml@xxxxxxxxxxxxxxxx, davem@xxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxx, yoshfuji@xxxxxxxxxxxxxx
In-reply-to: <1069974209.5349.7.camel@xxxxxxxxxxxxxxxxxxxxxxxx>
Organization: USAGI Project
References: <1069970770.2138.10.camel@xxxxxxxxxxxxxxxxxxxxxxxx> <20031127221928.F25015@xxxxxxxxxxxxxxxxxxxxxx> <1069974209.5349.7.camel@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
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

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