RE: [Fix v1] builtin/ls-files.c: add error check on lstat for modified files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On February 17, 2019 12:05, Ramsay Jones wrote:
> On 17/02/2019 16:34, randall.s.becker@xxxxxxxxxx wrote:
> > From: "Randall S. Becker" <rsbecker@xxxxxxxxxxxxx>
> >
> > The result from lstat, checking whether a file has been deleted, is
> > now included priot to calling id_modified when showing modified files.
> > Prior
> 
> s/priot/prior/; s/id_modified/ie_modified/
> 
> > to this fix, it is possible that files that were deleted could show up
> > as being modified because the lstat error was unchecked.
> >
> > Reported-by: Joe Ranieri <jranieri@xxxxxxxxxxxxxx>
> > Signed-off-by: Randall S. Becker <rsbecker@xxxxxxxxxxxxx>
> > ---
> >  builtin/ls-files.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/builtin/ls-files.c b/builtin/ls-files.c index
> > 29a8762d4..fc21f4795 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)
> 
> To be pedantic, this should probably check for (err == ENOENT), since
> lstat() can fail for several reasons which don't imply that the path has been
> deleted. However, that is unlikely.

That would be very platform specific error checking. lstat can fail for a variety of other reasons also leaving the file deleted (like a symlink issue), but you are correct. I was following the prior line's model of checking for consistency.

> No reason to include such a check in this patch, of course.
> 
> ATB,
> Ramsay Jones
> 
> >  				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);
> >  		}
> >  	}
> >

This was just to address what Joe reported earlier. It seemed like an easy one to address.

Regards,
Randall




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux