diff options
author | 1997-10-08 05:26:37 +0000 | |
---|---|---|
committer | 1997-10-08 05:26:37 +0000 | |
commit | b091175d22bb8dd491cda0ebf94ba418ba86ddf1 (patch) | |
tree | 4a467c00f4fe5306222306c81f79c2a02883bd09 /lib/libc/stdio/remove.c | |
parent | new file niklas added (diff) | |
download | wireguard-openbsd-b091175d22bb8dd491cda0ebf94ba418ba86ddf1.tar.xz wireguard-openbsd-b091175d22bb8dd491cda0ebf94ba418ba86ddf1.zip |
Use lstat() not stat() so we catch dangling symlinks, hubertf@netbsd.org
Also, update the man page to correspond to reality.
Diffstat (limited to 'lib/libc/stdio/remove.c')
-rw-r--r-- | lib/libc/stdio/remove.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libc/stdio/remove.c b/lib/libc/stdio/remove.c index 915149bc032..556925c7bf7 100644 --- a/lib/libc/stdio/remove.c +++ b/lib/libc/stdio/remove.c @@ -1,3 +1,5 @@ +/* $OpenBSD: remove.c,v 1.4 1997/10/08 05:26:38 millert Exp $ */ + /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -35,19 +37,24 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: remove.c,v 1.3 1996/10/28 04:55:25 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)remove.c 8.1 (Berkeley) 6/4/93"; +#else +static char rcsid[] = "$OpenBSD: remove.c,v 1.4 1997/10/08 05:26:38 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <stdio.h> #include <unistd.h> #include <sys/stat.h> +int remove(file) const char *file; { struct stat st; - if (stat(file, &st) < 0) + if (lstat(file, &st) < 0) return (-1); if (S_ISDIR(st.st_mode)) return (rmdir(file)); |