From owner-svn-src-head@freebsd.org Wed May 10 15:40:30 2017 Return-Path: Delivered-To: svn-src-head@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 CE455D66957; Wed, 10 May 2017 15:40:30 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-yb0-x234.google.com (mail-yb0-x234.google.com [IPv6:2607:f8b0:4002:c09::234]) (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 8C008A95; Wed, 10 May 2017 15:40:30 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-yb0-x234.google.com with SMTP id 8so8985484ybw.1; Wed, 10 May 2017 08:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=TII6qmWLolAjU/hzBG+SwsRa56jyoSx6OmYSPvDnZSw=; b=eWYQ0NGFlKofduqObRkDlnPjV0eAKQRmKmlIzWHPyzy8xkvt1LQXTy5YXVdZ7ZWoNJ ciXl1SiFPr26Mnc666jmVJVpX6hqxtwrUm68JZK8bq8+1Cfx7f8th6Y72qM8bEYn3fi3 AnMZoLY85yGdaV4XMtI7c/lVqCpegIhe8y+ghOvtEuBpTqPgutyj2O51pbFCsNuG0e// khoQZVDvhTe2Mbl788Z6rbnubK0GEGyMhA4pDwQbLPMfqTwrUcoxQXrCJgp0woff+DKy Jq5YYUUYlN/8kXa5MxUovytSJ1obeScVBNG/GnjpVZqL+Q3zBVDzt74l7SnWr6VvHLZo l32A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=TII6qmWLolAjU/hzBG+SwsRa56jyoSx6OmYSPvDnZSw=; b=fK4tleFomDZBebCam/x8DCzWO0Scf8wrQHd5YaW3oihCGiYyZxFs9kCXYEiq8nfQri NZo9XwBRxcvOgn92v7H3CyuH4LeHlbUHGD8+2xzIpGOfWRJJhvXpeA/hS4QexPYwW/mM O7cEdjo+irOyqRYgoiOqDo94klDvEeP2s8KvOTIQ0udumTopbqoOOhBtDA56LRzhIK2r Op0ckg/g/nvzobnmaCgnZPhfaBqH5OXGgmhZYA3nTohUm8AD9ysNM9zNo1IQZ7JDDDSA JSrRmnBfVXB3JJOxSygUCTW/te59k2VlQpzQm8iU+juAUviO54qBTFi8lzmfEsiTIKZ8 gsGA== X-Gm-Message-State: AODbwcDem0rn031G8CdbQUYLVUXUaerrI1EUR+3oW/eQed0DkWCsKchF Iy+un5oPsWylMQyk7r3Sw0PeQKCUEQ== X-Received: by 10.37.220.15 with SMTP id y15mr5261134ybe.16.1494430829165; Wed, 10 May 2017 08:40:29 -0700 (PDT) MIME-Version: 1.0 Sender: asomers@gmail.com Received: by 10.129.20.214 with HTTP; Wed, 10 May 2017 08:40:28 -0700 (PDT) In-Reply-To: References: <201705101527.v4AFRbbu005469@repo.freebsd.org> From: Alan Somers Date: Wed, 10 May 2017 09:40:28 -0600 X-Google-Sender-Auth: fyMpEvAtUS1LRyuxDgvpHDs6-K8 Message-ID: Subject: Re: svn commit: r318141 - head/usr.bin/mkuzip To: Warner Losh Cc: src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 May 2017 15:40:30 -0000 Hmm. I thought that assert(e) would get turned into e when -DNDEBUG. But looking at the header, you're right. I'll fix it soon. Good catch. -Alan On Wed, May 10, 2017 at 9:32 AM, Warner Losh wrote: > Doesn't assert get compiled out, which would cause strlcpy to never happen? > > Warner > > On Wed, May 10, 2017 at 9:27 AM, Alan Somers wrote: >> Author: asomers >> Date: Wed May 10 15:27:36 2017 >> New Revision: 318141 >> URL: https://svnweb.freebsd.org/changeset/base/318141 >> >> Log: >> strcpy => strlcpy >> >> Reported by: Coverity >> CID: 1352771 >> MFC after: 3 weeks >> Sponsored by: Spectra Logic Corp >> >> Modified: >> head/usr.bin/mkuzip/mkuzip.c >> >> Modified: head/usr.bin/mkuzip/mkuzip.c >> ============================================================================== >> --- head/usr.bin/mkuzip/mkuzip.c Wed May 10 15:20:39 2017 (r318140) >> +++ head/usr.bin/mkuzip/mkuzip.c Wed May 10 15:27:36 2017 (r318141) >> @@ -192,7 +192,8 @@ int main(int argc, char **argv) >> /* Not reached */ >> } >> >> - strcpy(hdr.magic, cfs.handler->magic); >> + assert(strlcpy(hdr.magic, cfs.handler->magic, sizeof(hdr.magic)) >> + < sizeof(hdr.magic)); >> >> if (cfs.en_dedup != 0) { >> hdr.magic[CLOOP_OFS_VERSN] = CLOOP_MAJVER_3; >>