From owner-svn-src-all@freebsd.org Tue May 3 19:00:12 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 92AD2B2C46B for ; Tue, 3 May 2016 19:00:12 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com [IPv6:2a00:1450:400c:c09::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 227311ED2 for ; Tue, 3 May 2016 19:00:12 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-wm0-x22d.google.com with SMTP id a17so55990908wme.0 for ; Tue, 03 May 2016 12:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=+hdFUyDloUKzsRfJeaIQmWKMt12y5ujeO4ANZx4vygQ=; b=ECFWE9FtCQJ7oCouupiP2W5LQgCS+nq38Rh+qN7X4C8vgQm+Xjy0LNcT17F1aGGDXj JOEIJu4EpIsnFnaEiuOIYd7R4CrOjYmdYHojuIJNH/v3yRue9JghPXCG6bkfC3mr0spZ NGUDIqT1jGzGn3Rq+TeDdSg6A3hllB9ZuS3A0HmliCsD2ySwJtxoST96LDUHLe9cuCIK P7vtvncH2Zpxk4zIbVQ3tBXcoxQP0s+Ucc3IeIVakRgNNpl6JsmDaAVmCX84yTCKh4Sb uUFS0FGUpHA2UtOsWHCvMrpygKClyc4HOMzMjpd0og5Olb36FWNwZuNjFQGwPgotNgKe XarA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=+hdFUyDloUKzsRfJeaIQmWKMt12y5ujeO4ANZx4vygQ=; b=JZk3a1fHhYUwxLWf+dTyIWVRQsLcVl7mVHjnC/pV+CsalPoQKCWqTJDwEDIpzf0p3A HjjoKOeVod3a8zz2gW8KJ7Obk299qa2n7NssRCNZEVbXCy1ef0EJZ5+tJy7j/pXBtU5j WH1PX2WDLh2tV6GulQ+qfhzyvqb+ha08dxeokScdZB+8umVpaO2scjxEelez8OeoEfTq oSL8Onow34Xu34vdNHlkOEdjI0RcZQMXqRw58voLzNAhSIHcUwlIS+3oWsbSM0FCVmPC 09nR6/CLZeXSELwgLfutYF1YrNFrZVQJaUyEKuV0QWxcINhM8vUkp6j8wREo/bhNlU5G hUZw== X-Gm-Message-State: AOPr4FXPC2ARbDziE/bE4deAXQdDfO781qmjo93qXTrfQrqpNjNZ1hqhSyW2TrQ0KUi+1WVldV/7YWY/zObyOkJC MIME-Version: 1.0 X-Received: by 10.194.184.38 with SMTP id er6mr4354106wjc.93.1462302010314; Tue, 03 May 2016 12:00:10 -0700 (PDT) Received: by 10.194.30.35 with HTTP; Tue, 3 May 2016 12:00:10 -0700 (PDT) In-Reply-To: <201604262059.u3QKxLDl045059@repo.freebsd.org> References: <201604262059.u3QKxLDl045059@repo.freebsd.org> Date: Tue, 3 May 2016 21:00:10 +0200 Message-ID: Subject: Re: svn commit: r298665 - head/sys/dev/aacraid From: Oliver Pinter To: "Conrad E. Meyer" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2016 19:00:12 -0000 On 4/26/16, Conrad E. Meyer wrote: > Author: cem > Date: Tue Apr 26 20:59:21 2016 > New Revision: 298665 > URL: https://svnweb.freebsd.org/changeset/base/298665 > > Log: > aacraid(4): Fix some mostly trivial buffer overruns > > strcpy(3) emits a trailing nul byte, trampling fields after the intended > destination. Instead, use strncpy(3), intentionally leaving these fields > not nul-terminated. > > Reported by: Coverity > CIDs: 1031024, 1305463, 1305494, 1305545 > Sponsored by: EMC / Isilon Storage Division > > Modified: > head/sys/dev/aacraid/aacraid_cam.c > > Modified: head/sys/dev/aacraid/aacraid_cam.c > ============================================================================== > --- head/sys/dev/aacraid/aacraid_cam.c Tue Apr 26 20:36:32 2016 (r298664) > +++ head/sys/dev/aacraid/aacraid_cam.c Tue Apr 26 20:59:21 2016 (r298665) > @@ -568,9 +568,11 @@ aac_container_special_command(struct cam > p->additional_length = 31; > p->flags = SID_WBus16|SID_Sync|SID_CmdQue; > /* OEM Vendor defines */ > - strcpy(p->vendor,"Adaptec "); > - strcpy(p->product,"Array "); > - strcpy(p->revision,"V1.0"); > + strncpy(p->vendor, "Adaptec ", sizeof(p->vendor)); > + strncpy(p->product, "Array ", > + sizeof(p->product)); > + strncpy(p->revision, "V1.0", > + sizeof(p->revision)); strlcpy instead or adjust the p->vendors size? New defect(s) Reported-by: Coverity Scan Showing 4 of 4 defect(s) ** CID 125792: (BUFFER_SIZE) /sys/dev/aacraid/aacraid_cam.c: 574 in aac_container_special_command() /sys/dev/aacraid/aacraid_cam.c: 576 in aac_container_special_command() /sys/dev/aacraid/aacraid_cam.c: 573 in aac_container_special_command() ________________________________________________________________________________________________________ *** CID 125792: (BUFFER_SIZE) /sys/dev/aacraid/aacraid_cam.c: 574 in aac_container_special_command() 568 p->response_format = 2; 569 if (ccb->csio.dxfer_len >= 36) { 570 p->additional_length = 31; 571 p->flags = SID_WBus16|SID_Sync|SID_CmdQue; 572 /* OEM Vendor defines */ 573 strncpy(p->vendor, "Adaptec ", sizeof(p->vendor)); >>> CID 125792: (BUFFER_SIZE) >>> Calling strncpy with a source string whose length (16 chars) is greater than or equal to the size argument (16) will fail to null-terminate "p->product". 574 strncpy(p->product, "Array ", 575 sizeof(p->product)); 576 strncpy(p->revision, "V1.0", 577 sizeof(p->revision)); 578 } 579 } else { /sys/dev/aacraid/aacraid_cam.c: 576 in aac_container_special_command() 570 p->additional_length = 31; 571 p->flags = SID_WBus16|SID_Sync|SID_CmdQue; 572 /* OEM Vendor defines */ 573 strncpy(p->vendor, "Adaptec ", sizeof(p->vendor)); 574 strncpy(p->product, "Array ", 575 sizeof(p->product)); >>> CID 125792: (BUFFER_SIZE) >>> Calling strncpy with a source string whose length (4 chars) is greater than or equal to the size argument (4) will fail to null-terminate "p->revision". 576 strncpy(p->revision, "V1.0", 577 sizeof(p->revision)); 578 } 579 } else { 580 if (inq->page_code == SVPD_SUPPORTED_PAGE_LIST) { 581 struct scsi_vpd_supported_page_list *p = /sys/dev/aacraid/aacraid_cam.c: 573 in aac_container_special_command() 567 p->version = SCSI_REV_SPC2; 568 p->response_format = 2; 569 if (ccb->csio.dxfer_len >= 36) { 570 p->additional_length = 31; 571 p->flags = SID_WBus16|SID_Sync|SID_CmdQue; 572 /* OEM Vendor defines */ >>> CID 125792: (BUFFER_SIZE) >>> Calling strncpy with a source string whose length (8 chars) is greater than or equal to the size argument (8) will fail to null-terminate "p->vendor". 573 strncpy(p->vendor, "Adaptec ", sizeof(p->vendor)); 574 strncpy(p->product, "Array ", 575 sizeof(p->product)); 576 strncpy(p->revision, "V1.0", 577 sizeof(p->revision)); 578 } > } > } else { > if (inq->page_code == SVPD_SUPPORTED_PAGE_LIST) { > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" >