diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-10-06 23:32:50 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-10-06 23:32:50 +0000 |
commit | 15dee108f91314f44514c5045a851bec22f22fd2 (patch) | |
tree | 64a51b1e4c0b26a28f59efd5ced19b8545886869 /lib/libc/gen/fts.c | |
parent | d042ad0a2a321d6b685d1212df8e2c67b693ea38 (diff) |
Fix bug caused by trailing '/' stripping. Didn't always guarantee NULL
termination. Now we do.
Diffstat (limited to 'lib/libc/gen/fts.c')
-rw-r--r-- | lib/libc/gen/fts.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 43d0726c39d..63b395148fc 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fts.c,v 1.12 1997/09/20 17:33:45 millert Exp $ */ +/* $OpenBSD: fts.c,v 1.13 1997/10/06 23:32:49 millert Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #else -static char rcsid[] = "$OpenBSD: fts.c,v 1.12 1997/09/20 17:33:45 millert Exp $"; +static char rcsid[] = "$OpenBSD: fts.c,v 1.13 1997/10/06 23:32:49 millert Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -948,8 +948,9 @@ fts_alloc(sp, name, namelen) if ((p = malloc(len)) == NULL) return (NULL); - /* Copy the name plus the trailing NULL. */ - memmove(p->fts_name, name, namelen + 1); + /* Copy the name and guarantee NULL termination. */ + memmove(p->fts_name, name, namelen); + p->fts_name[namelen] = '\0'; if (!ISSET(FTS_NOSTAT)) p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2); |