|
Message-Id: <1488880058.29564.0@mail.zhasha.com>
Date: Tue, 07 Mar 2017 10:47:38 +0100
From: Joakim Sindholt <opensource@...sha.com>
To: musl@...ts.openwall.com
Subject: fix nftw when called with paths ending in slash(es)
I sent a version of this patch to the list previously but I believe the
opinion was that nftw should preserve slashes as best it could, so
here's one that does that.
Using the test program from man nftw:
$ ./a.out ftw
d 0 4096 ftw 0 ftw
d 1 4096 ftw/a 4 a
f 2 0 ftw/a/f 6 f
d 2 4096 ftw/a/d 6 d
d 3 4096 ftw/a/d/e 8 e
d 1 4096 ftw/b 4 b
f 2 0 ftw/b/g 6 g
f 1 0 ftw/c 4 c
$ ./a.out ftw/
d 0 4096 ftw 0 ftw
d 1 4096 ftw/a 4 a
f 2 0 ftw/a/f 6 f
d 2 4096 ftw/a/d 6 d
d 3 4096 ftw/a/d/e 8 e
d 1 4096 ftw/b 4 b
f 2 0 ftw/b/g 6 g
f 1 0 ftw/c 4 c
$ ./a.out ftw//
d 0 4096 ftw 0 ftw
d 1 4096 ftw//a 5 a
f 2 0 ftw//a/f 7 f
d 2 4096 ftw//a/d 7 d
d 3 4096 ftw//a/d/e 9 e
d 1 4096 ftw//b 5 b
f 2 0 ftw//b/g 7 g
f 1 0 ftw//c 5 c
And on the root
$ ./a.out / | sed 4q
d 0 4096 / 0 /
d 1 4096 /projects 1 projects
d 2 4096 /projects/p9.git 10 p9.git
d 3 4096 /projects/p9.git/hooks 17 hooks
$ ./a.out // | sed 4q
d 0 4096 // 1 /
d 1 4096 //projects 2 projects
d 2 4096 //projects/p9.git 11 p9.git
d 3 4096 //projects/p9.git/hooks 18 hooks
However glibc does this:
$ ./a.out / | sed 4q
d 0 4096 / 1
d 1 4096 /projects 1 projects
d 2 4096 /projects/p9.git 10 p9.git
d 3 4096 /projects/p9.git/hooks 17 hooks
The standard just says:
> The value of base is the offset of the object's filename in the
> pathname passed as the first argument to fn
Which I believe should be interpreted as the root dir being called /
but I'm not sure. It's a simple change either way.
View attachment "0001-fix-nftw-when-called-with-paths-ending-in-slash-es.patch" of type "text/x-patch" (1760 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.