Coverity warning: strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);

Matthew Jacob mj at feral.com
Sun May 2 00:58:12 UTC 2010


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.



More information about the freebsd-hackers mailing list