From 25f227b924443a71ee2e15eff342871864b05d01 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 5 Jan 2001 18:10:10 +0000 Subject: Update. * io/ftw.c (ftw_dir): Don't add a second slash at the beginning for searches from the root directory. Reported by loris [PR libc/1991]. * io/Makefile (tests): Add bug-ftw1. * io/bug-ftw1.c: New file. --- io/ftw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'io/ftw.c') diff --git a/io/ftw.c b/io/ftw.c index 01abb63782..18b60519f0 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 , 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) -- cgit 1.4.1