bugfindutils - Bugs: bug #48314, find -type f matches symlinks in...

 
 

bug #48314: find -type f matches symlinks in armel armhf and mipsel

Submitted by:  Andreas Metzler <ametzler>
Submitted on:  Sat 25 Jun 2016 10:45:15 AM UTC  
 
Category: findSeverity: 5 - Blocker
Item Group: Wrong resultStatus: Fixed
Privacy: PublicAssigned to: Bernhard Voelker <berny>
Originator Name: Maximiliano CuriaOpen/Closed: Open
Release: NoneFixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 16 Jul 2016 01:59:39 PM UTC, comment #5:

The C standard does not guarantee NULL pointers from xzalloc(), but POSIX does:
http://austingroupbugs.net/view.php?id=940

and GNU has relied on that for years, with no real complaints of a compiler/platform mis-handling NULL.

Eric Blake <ericb>
Project Administrator
Sat 16 Jul 2016 01:10:43 PM UTC, comment #4:

One minor nit about the use of xzalloc: it sets the bits to zero, but this is not guaranteed by the C standard to set pointer members to NULL (since NULL is not guaranteed to be all-bits-zero).

James Youngman <jay>
Project Administrator
Thu 30 Jun 2016 12:20:58 AM UTC, comment #3:

Thanks for the report, the detailed analysis and the patches.
As already mentioned this cannot be reproduced on x86_64.
I've adjusted the commit messages of all 3 patches, and - in Maximiliano's patch - additionally removed the now-superfluous
initializations to NULL/false.

Pushing the attached ("48314.patch") soon.

Thanks & have a nice day,
Berny

(file #37629)

Bernhard Voelker <berny>
Project MemberIn charge of this item.
Sat 25 Jun 2016 10:58:01 AM UTC, comment #2:

I have been wondering why the testsuite did not detect this and have found that the issue does not show up if -maxdepth is used.

Find attached a trivial two-patch series to detect the bug:

0001-Test-checked-for-features-in-installed-find.patch
find/testsuite/test_type-list.sh ran the find binary installed on the system /usr/bin/fin/find) instead of the just-built version to check find features.

0002-Detect-type-breakage-on-multiple-archs-48314.patch
Extend test_type-list.sh to also run trivial tests on "-type f" and "-type l" without -maxdepth 0.

cu Andreas

(file #37570, file #37571)

Andreas Metzler <ametzler>
Sat 25 Jun 2016 10:49:13 AM UTC, comment #1:

Hello,

this is https://bugs.debian.org/827724 originally submitted by Maximiliano Curia:
--------------------------
The new version of find has a weird behaviour, at least in the arches: armhf armel and mipsel.
As simple test:

dir=$(mktemp -d)
cd $dir
ln -s a b
find -type f

Shows ./b while it shouldn't.

Interestingly:
$ find -type l
find: Duplicate file type 'l' in the argument list to -type

Both examples work fine in amd64.

I haven't followed the code thoroughly, but it seems that the type is using a
float to hold a bit mask, maybe this is not so well behaved in all arches.

[...]
With the addition of multiple types in one -type option, the args union of the
predicate struct has grown and the new space is not being initialized.
(The initialization of args is done as a args.str = NULL, but args.types is a
bool types[FTYPE_COUNT]; with count being 8, that's 32 bytes vs 4 that are
currently initialized in a 32 bits arch.

Replacing the xmalloc invocation by a xzalloc one "fixes" the issue as it
initializes all of the predicate components.

I'm attaching a patch that does this.
-----------------------------------
This is against GIT head after 6c37ce48a1eb3d1f21a1848cc9c40f2cdb191e88.

(file #37569)

Andreas Metzler <ametzler>
Sat 25 Jun 2016 10:45:15 AM UTC, original submission:
Andreas Metzler <ametzler>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #37629:  48314.patch added by berny (6KiB - text/x-diff - patch series supposed to be pushed)
file #37570:  0001-Test-checked-for-features-in-installed-find.patch added by ametzler (949B - text/x-diff - Fix/extend test_type-list.sh.)
file #37571:  0002-Detect-type-breakage-on-multiple-archs-48314.patch added by ametzler (1KiB - text/x-diff - Fix/extend test_type-list.sh.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ericb (Posted a comment)
  • -unavailable- added by jay (Posted a comment)
  • -unavailable- added by berny (Updated the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 10 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 05 Jul 2016 02:39:31 PM UTCbernyStatusCode Review=>Fixed
    Thu 30 Jun 2016 12:20:58 AM UTCbernyAttached File-=>Added 48314.patch, #37629
      Severity3 - Normal=>5 - Blocker
      StatusIn Progress=>Code Review
    Wed 29 Jun 2016 09:19:00 PM UTCbernyStatusNone=>In Progress
      Assigned toNone=>berny
    Sat 25 Jun 2016 10:58:01 AM UTCametzlerAttached File-=>Added 0001-Test-checked-for-features-in-installed-find.patch, #37570
      Attached File-=>Added 0002-Detect-type-breakage-on-multiple-archs-48314.patch, #37571
    Sat 25 Jun 2016 10:50:55 AM UTCametzlerCarbon-CopyRemoved 20807=>-
    Sat 25 Jun 2016 10:49:13 AM UTCametzlerAttached File-=>Added replace_xmalloc_with_xzalloc.diff, #37569

    Back to the top


    Powered by Savane 3.1-cleanup1