Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 01 May 2010 17:58:48 -0700
From:      Matthew Jacob <mj@feral.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Coverity warning: strncpy(cpi->dev_name, cam_sim_name(sim),	DEV_IDLEN); 
Message-ID:  <4BDCCE48.4070900@feral.com>
In-Reply-To: <20100501223524.GU36233@elvis.mu.org>
References:  <20100501223524.GU36233@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 5/1/2010 3:35 PM, Alfred Perlstein wrote:
> I notice this code sprinkled through the sources:
>    strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
>
> This trips up coverity because it does not know for sure
> that the string returned by cam_sim_name() is going to
> be DEV_IDLEN-1 characters long.
>
> Should we switch these calls to strlcpy?  Is there a smarter
> thing to do to code more defensively?
>
>    

strlcpy seems right.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4BDCCE48.4070900>