From owner-svn-src-head@freebsd.org Wed Apr 12 18:30:10 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 197D4D3B118 for ; Wed, 12 Apr 2017 18:30:10 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-io0-x231.google.com (mail-io0-x231.google.com [IPv6:2607:f8b0:4001:c06::231]) (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 DB634771 for ; Wed, 12 Apr 2017 18:30:09 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-io0-x231.google.com with SMTP id a103so53314017ioj.1 for ; Wed, 12 Apr 2017 11:30:09 -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=8rCAp7vIzYvlYtUfzWotWPi/p0fCAejfcKQQGhHtqj8=; b=B7ihqaBr8Yxl6RzvePE//wOUF5qRhIoOjbbLjGickcS3VFAFhtd3D/+7x/CloHaZX3 eEaui24+lM4bleTGypULLqWwQW0uz/0u/9SQAy4scgJBLc08B7ct2ro91WmNqNJDKml6 pHCGX9AAjpQK5VCptKHvsUj78b6jlclKB/cwWVVSnYTAYmZDNNshOp2H+5bu12Stdjz5 qTo9pUrPP5RU2/mtAnKDBvazPAh80LsN4NDPJAxE6kVNKeEi0kFncM1bh2Tshqb25pyX 1db8cXZOv8AXprfJqVzurMZpmsu6ryyxm5BKcDC0yOVSegg3ZzR89TxSUIhQ4RR4JiBh 7v+Q== 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=8rCAp7vIzYvlYtUfzWotWPi/p0fCAejfcKQQGhHtqj8=; b=WNj9Jr4mFMFr1YRv/iO6CkXvWziIS6Lh8NajHrVs25t4W+PuBzqjXMRIwNz9O2wzD1 /sJLfFXWNbcOPZGqT8vJNym0scx7Y3SNbSy1DJPDUPqxg6Mn6KF9+1RV9Es2q6DIBs8I W3ulc1wN5qLTlOtT6Xna8E6bfB78hsnRFUzKj324XyfAOYKRt4AjLWkwpBYms/PvLbLu 8c3vTA1bZsCpTBK0nPJvtlWxuIojG3QBrQ3CeeU4a/V1zLGi7bhnyEzl9hNIJk/dMTqD 0dkdo/XJrzl6tljzWkZEkqJlXYBrkOJa6G4ROyd74sZ285D1sLe41qE9pHMf3Ms88tES 3V3g== X-Gm-Message-State: AN3rC/6reBUjKvXguH4ezyRdtseuGYtKbKlmRqU7bHYasX7gNX5uELxg NVXWGULQzTxQXuhx1BilPKhNpwOfg2SA X-Received: by 10.36.74.196 with SMTP id k187mr23598993itb.49.1492021809131; Wed, 12 Apr 2017 11:30:09 -0700 (PDT) MIME-Version: 1.0 Sender: sobomax@sippysoft.com Received: by 10.36.112.210 with HTTP; Wed, 12 Apr 2017 11:30:08 -0700 (PDT) In-Reply-To: References: <201704112155.v3BLtepk065823@repo.freebsd.org> From: Maxim Sobolev Date: Wed, 12 Apr 2017 11:30:08 -0700 X-Google-Sender-Auth: Cimcvlq5itCR34mMPUJtEmU35dI Message-ID: Subject: Re: svn commit: r316718 - head/sbin/mksnap_ffs 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: Wed, 12 Apr 2017 18:30:10 -0000 Ah, that's right. Good catch, sorry about that. I will fix it momentarily. -Maxim On Wed, Apr 12, 2017 at 8:51 AM, Conrad Meyer wrote: > Hi Maxim, > > This breaks several stbuf checks in main() following the stat() call > you removed to isdir(). Coverity reported this as CID 1374247. > > On Tue, Apr 11, 2017 at 2:55 PM, Maxim Sobolev > wrote: > > Author: sobomax > > Date: Tue Apr 11 21:55:39 2017 > > New Revision: 316718 > > URL: https://svnweb.freebsd.org/changeset/base/316718 > > > > ... > > --- head/sbin/mksnap_ffs/mksnap_ffs.c Tue Apr 11 20:28:15 2017 > (r316717) > > +++ head/sbin/mksnap_ffs/mksnap_ffs.c Tue Apr 11 21:55:39 2017 > (r316718) > > @@ -58,6 +58,33 @@ usage(void) > > errx(EX_USAGE, "usage: mksnap_ffs snapshot_name"); > > } > > > > +static int > > +isdir(const char *path) > > +{ > > + struct stat stbuf; > > + > > + if (stat(path, &stbuf) < 0) > > + return (-1); > ^^^^^^^^^^^^^^^^^^ moved here > > > + if (!S_ISDIR(stbuf.st_mode)) > > + return (0); > > + return (1); > > +} > > ... > > @@ -96,16 +123,33 @@ main(int argc, char **argv) > > } > > if (statfs(path, &stfsbuf) < 0) > > err(1, "%s", path); > > - if (stat(path, &stbuf) < 0) > ^^^^^^^^^^^^^^^^^^^ from here > > > + switch (isdir(path)) { > > + case -1: > > err(1, "%s", path); > > - if (!S_ISDIR(stbuf.st_mode)) > > + case 0: > > errx(1, "%s: Not a directory", path); > > + default: > > + break; > > + } > > if (access(path, W_OK) < 0) > > err(1, "Lack write permission in %s", path); > > if ((stbuf.st_mode & S_ISTXT) && stbuf.st_uid != getuid()) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ now uninitialized use > >