FreeBSD Bugzilla – Attachment 9555 Details for
Bug 19536
patch to prevent head'ing directories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 1.29 KB, created by
kbyanc
on 2000-06-27 01:50:00 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
kbyanc
Created:
2000-06-27 01:50:00 UTC
Size:
1.29 KB
patch
obsolete
>Index: usr.bin/head/head.c >=================================================================== >RCS file: /home/cvs/src/usr.bin/head/head.c,v >retrieving revision 1.10 >diff -u -r1.10 head.c >--- usr.bin/head/head.c 1999/08/28 01:01:58 1.10 >+++ usr.bin/head/head.c 2000/06/27 00:40:28 >@@ -45,6 +45,7 @@ > "$FreeBSD: src/usr.bin/head/head.c,v 1.10 1999/08/28 01:01:58 peter Exp $"; > #endif /* not lint */ > >+#include <sys/stat.h> > #include <sys/types.h> > > #include <ctype.h> >@@ -73,6 +74,7 @@ > char *argv[]; > { > register int ch; >+ struct stat sb; > FILE *fp; > int first, linecnt = -1, bytecnt = -1; > char *ep; >@@ -103,11 +105,22 @@ > linecnt = 10; > if (*argv) { > for (first = 1; *argv; ++argv) { >- if ((fp = fopen(*argv, "r")) == NULL) { >+ if ((fp = fopen(*argv, "r")) == NULL || >+ fstat(fileno(fp), &sb)) { > warn("%s", *argv); > eval = 1; > continue; > } >+ if (sb.st_mode & S_IFDIR) >+ errx(1, "%s is a directory", *argv); >+ if (sb.st_mode & S_IFLNK) >+ /* This should transparently be resolved and >+ * thus never happen. >+ */ >+ errx(1, "%s is a symlink", *argv); >+ if (sb.st_mode & S_IFWHT) >+ /* This should never happen. */ >+ errx(1, "%s is a whiteout entry", *argv); > if (argc > 1) { > (void)printf("%s==> %s <==\n", > first ? "" : "\n", *argv);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 19536
: 9555