From owner-freebsd-hackers@FreeBSD.ORG Sun May 2 00:58:12 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4C503106566B for ; Sun, 2 May 2010 00:58:12 +0000 (UTC) (envelope-from mj@feral.com) Received: from ns1.feral.com (ns1.feral.com [192.67.166.1]) by mx1.freebsd.org (Postfix) with ESMTP id 2B7488FC18 for ; Sun, 2 May 2010 00:58:11 +0000 (UTC) Received: from [192.168.0.102] (m206-63.dsl.tsoft.com [198.144.206.63]) by ns1.feral.com (8.14.3/8.14.3) with ESMTP id o420wBfn049943 for ; Sat, 1 May 2010 17:58:11 -0700 (PDT) (envelope-from mj@feral.com) Message-ID: <4BDCCE48.4070900@feral.com> Date: Sat, 01 May 2010 17:58:48 -0700 From: Matthew Jacob User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <20100501223524.GU36233@elvis.mu.org> In-Reply-To: <20100501223524.GU36233@elvis.mu.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Default is to whitelist mail, not delayed by milter-greylist-4.2.3 (ns1.feral.com [192.67.166.1]); Sat, 01 May 2010 17:58:11 -0700 (PDT) Subject: Re: Coverity warning: strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 May 2010 00:58:12 -0000 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.