aboutsummaryrefslogtreecommitdiff
path: root/io/ftw.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-01-05 18:10:10 +0000
committerUlrich Drepper <drepper@redhat.com>2001-01-05 18:10:10 +0000
commit25f227b924443a71ee2e15eff342871864b05d01 (patch)
tree1e55d7ca3743b0ed5eb62e8a9ecabae47d53dcea /io/ftw.c
parent155fd00c743bd428a78ed66c3743bc9f8b4a13b1 (diff)
downloadglibc-25f227b924443a71ee2e15eff342871864b05d01.zip
glibc-25f227b924443a71ee2e15eff342871864b05d01.tar.gz
glibc-25f227b924443a71ee2e15eff342871864b05d01.tar.bz2
Update.
* io/ftw.c (ftw_dir): Don't add a second slash at the beginning for searches from the root directory. Reported by loris <loris@iol.it> [PR libc/1991]. * io/Makefile (tests): Add bug-ftw1. * io/bug-ftw1.c: New file.
Diffstat (limited to 'io/ftw.c')
-rw-r--r--io/ftw.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/io/ftw.c b/io/ftw.c
index 01abb63..18b6051 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -1,5 +1,5 @@
/* File tree walker functions.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -396,7 +396,10 @@ ftw_dir (struct ftw_data *data, struct STAT *st)
/* Next, update the `struct FTW' information. */
++data->ftw.level;
startp = strchr (data->dirbuf, '\0');
- *startp++ = '/';
+ /* There always must be a directory name. */
+ assert (startp != data->dirbuf);
+ if (startp != data->dirbuf + 1)
+ *startp++ = '/';
data->ftw.base = startp - data->dirbuf;
while (dir.stream != NULL && (d = READDIR (dir.stream)) != NULL)