From 3beb1a70cf622b069465e9fa4e5d174f89d8bef4 Mon Sep 17 00:00:00 2001 From: pk Date: Tue, 7 Oct 1997 23:02:17 +0000 Subject: [PATCH] In fts_alloc() copy the trailing 0 character explicitly, instead of relying on the passed input string having a 0 character at the right spot. Takes care of PR#4234. --- lib/libc/gen/fts.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index f2eb1b217b49..25b940ee1ee9 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1,4 +1,4 @@ -/* $NetBSD: fts.c,v 1.16 1997/09/27 22:53:07 pk Exp $ */ +/* $NetBSD: fts.c,v 1.17 1997/10/07 23:02:17 pk Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)fts.c 8.4 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: fts.c,v 1.16 1997/09/27 22:53:07 pk Exp $"); +__RCSID("$NetBSD: fts.c,v 1.17 1997/10/07 23:02:17 pk Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -932,8 +932,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, then append the trailing NULL. */ + 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);