Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1462369339.29574.1@mail.zhasha.com>
Date: Wed, 04 May 2016 15:42:19 +0200
From: Joakim Sindholt <opensource@...sha.com>
To: musl@...ts.openwall.com
Subject: nftw miscalculates FTW.base when pathnames end in /

Running the test program from the glibc ftw man page[1]:

+zhasha@...belwind /home/zhasha ; ./6.out test
d    0    4096   test                                     0 test
d    1    4096   test/a                                   5 a
f    2       0   test/a/1                                 7 1
d    1    4096   test/b                                   5 b
f    2       0   test/b/1                                 7 1
f    2       0   test/b/2                                 7 2
d    1    4096   test/ddd                                 5 ddd
f    2       0   test/ddd/5                               9 5
d    1    4096   test/cc                                  5 cc
f    2       0   test/cc/3                                8 3
+zhasha@...belwind /home/zhasha ; ./6.out test/
d    0    4096   test/                                    4 /
d    1    4096   test/a                                   6
f    2       0   test/a/1                                 7 1
d    1    4096   test/b                                   6
f    2       0   test/b/1                                 7 1
f    2       0   test/b/2                                 7 2
d    1    4096   test/ddd                                 6 dd
f    2       0   test/ddd/5                               9 5
d    1    4096   test/cc                                  6 c
f    2       0   test/cc/3                                8 3

The final 2 columns are the file name length and path + ftw->base
respectively, which is off by one when the path ends in /. It also
seems to confuse the initial dir name.

I have attached a fix but I'm not sure it's a particularly good one.

[1] http://linux.die.net/man/3/ftw

View attachment "nftw.patch" of type "text/x-patch" (564 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.