FreeBSD Bugzilla – Attachment 201110 Details for
Bug 234885
cmp(1) Capsicum error if stdin closed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
diff (text/plain), 1.76 KB, created by
Mark Johnston
on 2019-01-14 03:47:17 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Mark Johnston
Created:
2019-01-14 03:47:17 UTC
Size:
1.76 KB
patch
obsolete
>diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c >index b8d5dba14ec4..c0335c336f6c 100644 >--- a/usr.bin/cmp/cmp.c >+++ b/usr.bin/cmp/cmp.c >@@ -120,10 +120,9 @@ main(int argc, char *argv[]) > special = 0; > if (strcmp(file1 = argv[0], "-") == 0) { > special = 1; >- fd1 = 0; >+ fd1 = STDIN_FILENO; > file1 = "stdin"; >- } >- else if ((fd1 = open(file1, oflag, 0)) < 0 && errno != EMLINK) { >+ } else if ((fd1 = open(file1, oflag, 0)) < 0 && errno != EMLINK) { > if (!sflag) > err(ERR_EXIT, "%s", file1); > else >@@ -134,10 +133,9 @@ main(int argc, char *argv[]) > errx(ERR_EXIT, > "standard input may only be specified once"); > special = 1; >- fd2 = 0; >+ fd2 = STDIN_FILENO; > file2 = "stdin"; >- } >- else if ((fd2 = open(file2, oflag, 0)) < 0 && errno != EMLINK) { >+ } else if ((fd2 = open(file2, oflag, 0)) < 0 && errno != EMLINK) { > if (!sflag) > err(ERR_EXIT, "%s", file2); > else >@@ -175,15 +173,17 @@ main(int argc, char *argv[]) > if (caph_fcntls_limit(fd2, fcntls) < 0) > err(ERR_EXIT, "unable to limit fcntls for %s", file2); > >- if (!special) { >+ if (!special && fd1 != STDIN_FILENO && fd2 != STDIN_FILENO) { > cap_rights_init(&rights); >- if (caph_rights_limit(STDIN_FILENO, &rights) < 0) { >+ if (caph_rights_limit(STDIN_FILENO, &rights) < 0) > err(ERR_EXIT, "unable to limit stdio"); >- } > } >- >- if (caph_limit_stdout() == -1 || caph_limit_stderr() == -1) >- err(ERR_EXIT, "unable to limit stdio"); >+ if (fd1 != STDOUT_FILENO && fd2 != STDOUT_FILENO && >+ fcntl(STDOUT_FILENO, F_GETFL) == 0 && caph_limit_stdout() == -1) >+ err(ERR_EXIT, "unable to limit stdout"); >+ if (fd1 != STDERR_FILENO && fd2 != STDERR_FILENO && >+ fcntl(STDERR_FILENO, F_GETFL) == 0 && caph_limit_stderr() == -1) >+ err(ERR_EXIT, "unable to limit stderr"); > > caph_cache_catpages(); >
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 234885
:
201110
|
201112