git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Randall S. Becker" <rsbecker@nexbridge.com>
To: "'Joe Ranieri'" <jranieri@grammatech.com>, <git@vger.kernel.org>
Subject: RE: [BUG] ls-files showing deleted files (unchecked lstat return value)
Date: Sun, 17 Feb 2019 10:59:12 -0500	[thread overview]
Message-ID: <000001d4c6d9$bceb5810$36c20830$@nexbridge.com> (raw)
In-Reply-To: <1ff48830-f3de-11f4-9014-c20eb3890c21@grammatech.com>

On February 17, 2019 8:50, Joe Ranieri wrote:
> "git ls-files -m" can show deleted files, despite -d not having been specified.
> This is due to ls-files.c's show_files function calling lstat but not checking the
> return value before calling ie_modified with the uninitialized stat structure.

What version of git are you looking scanning? Commit 8989e1950a (2.21.0-rc1) has the following:

err = lstat(fullname.buf, &st);
if (show_deleted && err)
...

You may be correct that the following check:
 if (show_modified && ie_modified(repo->index, ce, &st, 0

may need to include !err. Is that your conclusion? Is there a test case you have to demonstrate this that I can include in the test suite?

The patch would be (subject to my bad mailer messing it up):

diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 29a8762d46..fc21f47954 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -348,7 +348,7 @@ static void show_files(struct repository *repo, struct dir_struct *dir)
                        err = lstat(fullname.buf, &st);
                        if (show_deleted && err)
                                show_ce(repo, dir, ce, fullname.buf, tag_removed);
-                       if (show_modified && ie_modified(repo->index, ce, &st, 0))
+                       if (show_modified && !err && ie_modified(repo->index, ce, &st, 0))
                                show_ce(repo, dir, ce, fullname.buf, tag_modified);
                }
        }

Regards,
Randall

-- Brief whoami:
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.




  reply	other threads:[~2019-02-17 15:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-17 13:49 [BUG] ls-files showing deleted files (unchecked lstat return value) Joe Ranieri
2019-02-17 15:59 ` Randall S. Becker [this message]
2019-02-18 14:09   ` Joe Ranieri
2019-02-18 15:17 ` SZEDER Gábor
2019-02-18 16:14   ` Randall S. Becker
2019-02-20 22:51   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000001d4c6d9$bceb5810$36c20830$@nexbridge.com' \
    --to=rsbecker@nexbridge.com \
    --cc=git@vger.kernel.org \
    --cc=jranieri@grammatech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).