Created
January 5, 2017 21:49
-
-
Save vathpela/17d2e9d2ee3352be78e7d3b514359e2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit a4e941d94849c032c60a9ac2465b6bd05fd51e2a | |
Author: Peter Jones <[email protected]> | |
Date: Thu Jan 5 16:47:25 2017 -0500 | |
rpm2cpio and rpm2archive: don't write archive data to a terminal. | |
Signed-off-by: Peter Jones <[email protected]> | |
diff --git a/rpm2archive.c b/rpm2archive.c | |
index 8660e21..5443846 100644 | |
--- a/rpm2archive.c | |
+++ b/rpm2archive.c | |
@@ -120,7 +120,11 @@ static int process_package(rpmts ts, char * filename) | |
archive_write_set_format_pax_restricted(a); | |
if (!strcmp(filename, "-")) { | |
- archive_write_open_fd(a, 1); | |
+ if (isatty(STDOUT_FILENO)) { | |
+ fprintf(stderr, "%s: refusing to output archive data to a terminal.\n"); | |
+ exit(EXIT_FAILURE); | |
+ } | |
+ archive_write_open_fd(a, STDOUT_FILENO); | |
} else { | |
char * outname = rstrscat(NULL, filename, ".tgz", NULL); | |
archive_write_open_filename(a, outname); | |
diff --git a/rpm2cpio.c b/rpm2cpio.c | |
index d4bf366..131a1c3 100644 | |
--- a/rpm2cpio.c | |
+++ b/rpm2cpio.c | |
@@ -38,6 +38,10 @@ int main(int argc, char *argv[]) | |
(argc == 1 ? "<stdin>" : argv[1]), Fstrerror(fdi)); | |
exit(EXIT_FAILURE); | |
} | |
+ if (isatty(STDOUT_FILENO)) { | |
+ fprintf(stderr, "%s: refusing to output cpio data to a terminal.\n"); | |
+ exit(EXIT_FAILURE); | |
+ } | |
fdo = fdDup(STDOUT_FILENO); | |
{ rpmts ts = rpmtsCreate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment