From owner-svn-src-head@freebsd.org Fri Jun 23 17:39:40 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 C4011D860F1 for ; Fri, 23 Jun 2017 17:39:40 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-vk0-x22f.google.com (mail-vk0-x22f.google.com [IPv6:2607:f8b0:400c:c05::22f]) (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 817636A552 for ; Fri, 23 Jun 2017 17:39:40 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-vk0-x22f.google.com with SMTP id y70so17081089vky.3 for ; Fri, 23 Jun 2017 10:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sippysoft-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=APSenA+f29J3C1epkOnv009qVhLMJ1SyT2mBV//+KFg=; b=sA+4thse15CbzRuVcuxU1mzg6dwmrCYUKok0CyHgzWbLljZq/JFksjewdCZAYa85WW pKUM9aGAjcGCwU0FXAelAHj9mArA7RJx7qxc8mG48vx+Z5kvuSsUslINyz8ID3qR/Pm4 v+pi+K1BjU0rTklKUNZov2JMJFWO05HGoFAJom8grfC6KQ6H8xFymLzkvb4zvLtNuJpH 8ZzeNhTAL8ugD6r6donkU90FTM6n9hYPW38pX8j8FbI5qRVTpA06X1k/JBdcoRn6QpXQ pw/SFIjx24qqcEtK/TBAeKqxQ/4YwwDwUg9CH0cowFyRVqVdmkgL7jR4woWw23HgTYJC ALhA== 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=APSenA+f29J3C1epkOnv009qVhLMJ1SyT2mBV//+KFg=; b=nQP+nfUdJRqgJ/VQtQPfRRuwuLyi81Zqd0kFoqrBlgqoALMbxYMF1/krEJTcdgY5Mc cnFHUMaBziz85CkdC6tqBh/gACG2hsnH18/OsvQ5WjsPZe3GSNGNPH8ozijrOzmBTp2x un22j0WxwKMh8kI/eQ7lfbC1GQXlFItKwkgUqF2v8pZLDnMeODoMNTgSBjXUcMviwq5U 1sRuvf/GjNKr2t4XoGl1udGP0S+oTm5/0t6dIWKIj5gFZPYRp3EJwAX9V3nIYLQ0GdOM /kvGEsHcMXwg99SoeYjoPMCH1oZGtx11GmgKWLybQB5c9YUvqdi1gaUPJGVsbyrhq2TK qsmQ== X-Gm-Message-State: AKS2vOwb/f/hOjZrD7ECj12nPBrKOrn0RhugzVxvNM2KRLj3Fiy3LM7q nV2vNI9HgVLHUllhH5Mv1DaetyoO6AuZ X-Received: by 10.31.196.69 with SMTP id u66mr3353689vkf.47.1498239579357; Fri, 23 Jun 2017 10:39:39 -0700 (PDT) MIME-Version: 1.0 Sender: sobomax@sippysoft.com Received: by 10.176.16.76 with HTTP; Fri, 23 Jun 2017 10:39:38 -0700 (PDT) In-Reply-To: References: <201706170258.v5H2wWCT006080@repo.freebsd.org> From: Maxim Sobolev Date: Fri, 23 Jun 2017 10:39:38 -0700 X-Google-Sender-Auth: qT6z4SMbtKZ5NWriPC69TAv1W9k Message-ID: Subject: Re: svn commit: r320048 - head/usr.bin/mkuzip To: "Conrad E. Meyer" Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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: Fri, 23 Jun 2017 17:39:40 -0000 Sorry overlooked that. Fixed, thanks! -Maxim On Thu, Jun 22, 2017 at 5:13 PM, Conrad Meyer wrote: > ffd is leaked in return paths. Coverity CID 1376420. > > On Fri, Jun 16, 2017 at 7:58 PM, Maxim Sobolev > wrote: > > Author: sobomax > > Date: Sat Jun 17 02:58:31 2017 > > New Revision: 320048 > > URL: https://svnweb.freebsd.org/changeset/base/320048 > > > > Log: > > o Move logic that determines size of the input image into its own > > file. That logic has grown quite significantly now; > > > > o add a special handling for the snapshot images. Those have some > > extra headers at the end of the image and we don't need those > > in the output image really. > > > > MFC after: 6 weeks > > > > ... > > Added: head/usr.bin/mkuzip/mkuz_insize.c > > ... > > +off_t > > +mkuz_get_insize(struct mkuz_cfg *cfp) > > +{ > > + int ffd; > > + off_t ms; > > + struct stat sb; > > + struct statfs statfsbuf; > > + > > + if (fstat(cfp->fdr, &sb) != 0) { > > + warn("fstat(%s)", cfp->iname); > > + return (-1); > > + } > > + if ((sb.st_flags & SF_SNAPSHOT) != 0) { > > + if (fstatfs(cfp->fdr, &statfsbuf) != 0) { > > + warn("fstatfs(%s)", cfp->iname); > > + return (-1); > > + } > > + ffd = open(statfsbuf.f_mntfromname, O_RDONLY); > > + if (ffd < 0) { > > + warn("open(%s, O_RDONLY)", > statfsbuf.f_mntfromname); > > + return (-1); > > + } > > + if (ioctl(ffd, DIOCGMEDIASIZE, &ms) < 0) { > > + warn("ioctl(DIOCGMEDIASIZE)"); > > + return (-1); > > ffd leaked here. > > > + } > > ffd also leaked here via fallthrough return. > > > + sb.st_size = ms; > > + } else if (S_ISCHR(sb.st_mode)) { > > + if (ioctl(cfp->fdr, DIOCGMEDIASIZE, &ms) < 0) { > > + warn("ioctl(DIOCGMEDIASIZE)"); > > + return (-1); > > + } > > + sb.st_size = ms; > > + } else if (!S_ISREG(sb.st_mode)) { > > + warnx("%s: not a character device or regular file\n", > > + cfp->iname); > > + return (-1); > > + } > > + return (sb.st_size); > > +} > >