diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-08-27 21:42:07 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-08-27 21:42:07 +0000 |
commit | 79d5917fdd0822932b522b42c36051b60180260d (patch) | |
tree | 34324d45a5602d2fe6d8498e992adb9702c59c7e /lib | |
parent | f54642e16d7e7925ddb56ac93f226a4519ce8183 (diff) |
Zero out entire FTS after allocating it instead of just zeroing out
a few fields by hand; Closes PR 2033
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/fts.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 741d07cacca..60409450cfd 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fts.c,v 1.28 2001/08/03 22:23:48 millert Exp $ */ +/* $OpenBSD: fts.c,v 1.29 2001/08/27 21:42:06 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.28 2001/08/03 22:23:48 millert Exp $"; +static char rcsid[] = "$OpenBSD: fts.c,v 1.29 2001/08/27 21:42:06 millert Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -95,7 +95,7 @@ fts_open(argv, options, compar) } /* Allocate/initialize the stream */ - if ((sp = malloc((u_int)sizeof(FTS))) == NULL) + if ((sp = malloc(sizeof(FTS))) == NULL) return (NULL); memset(sp, 0, sizeof(FTS)); sp->fts_compar = compar; @@ -958,19 +958,14 @@ fts_alloc(sp, name, namelen) if ((p = malloc(len)) == NULL) return (NULL); - /* Copy the name and guarantee NUL 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); - p->fts_namelen = namelen; + memset(p, 0, len); p->fts_path = sp->fts_path; - p->fts_errno = 0; - p->fts_flags = 0; + p->fts_namelen = namelen; p->fts_instr = FTS_NOINSTR; - p->fts_number = 0; - p->fts_pointer = NULL; + if (!ISSET(FTS_NOSTAT)) + p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2); + memcpy(p->fts_name, name, namelen); + return (p); } |