76844ee24d
Resolves: #1083075 Version: 1.27.1-3
57 lines
1.7 KiB
Diff
57 lines
1.7 KiB
Diff
diff --git a/NEWS b/NEWS
|
||
index 1a264b0..c4dd8c6 100644
|
||
--- a/NEWS
|
||
+++ b/NEWS
|
||
@@ -12,6 +12,8 @@ version 1.27.1 - Sergey Poznyakoff, 2013-11-17
|
||
|
||
* Fix extracting sparse members from star archives.
|
||
|
||
+* Tar refuses to read input from and write output to a tty device.
|
||
+
|
||
|
||
version 1.27 - Sergey Poznyakoff, 2013-10-05
|
||
|
||
diff --git a/src/buffer.c b/src/buffer.c
|
||
index 4b44eaf..5ec8d31 100644
|
||
--- a/src/buffer.c
|
||
+++ b/src/buffer.c
|
||
@@ -633,6 +633,22 @@ init_buffer (void)
|
||
record_end = record_start + blocking_factor;
|
||
}
|
||
|
||
+static void
|
||
+check_tty (enum access_mode mode)
|
||
+{
|
||
+ /* Refuse to read archive from and write it to a tty. */
|
||
+ if (strcmp (archive_name_array[0], "-") == 0
|
||
+ && isatty (mode == ACCESS_READ ? STDIN_FILENO : STDOUT_FILENO))
|
||
+ {
|
||
+ FATAL_ERROR ((0, 0,
|
||
+ mode == ACCESS_READ
|
||
+ ? _("Refusing to read archive contents from terminal "
|
||
+ "(missing -f option?)")
|
||
+ : _("Refusing to write archive contents to terminal "
|
||
+ "(missing -f option?)")));
|
||
+ }
|
||
+}
|
||
+
|
||
/* Open an archive file. The argument specifies whether we are
|
||
reading or writing, or both. */
|
||
static void
|
||
@@ -653,6 +669,7 @@ _open_archive (enum access_mode wanted_access)
|
||
|
||
/* When updating the archive, we start with reading. */
|
||
access_mode = wanted_access == ACCESS_UPDATE ? ACCESS_READ : wanted_access;
|
||
+ check_tty (access_mode);
|
||
|
||
read_full_records = read_full_records_option;
|
||
|
||
@@ -696,7 +713,6 @@ _open_archive (enum access_mode wanted_access)
|
||
enum compress_type type;
|
||
|
||
archive = STDIN_FILENO;
|
||
-
|
||
type = check_compressed_archive (&shortfile);
|
||
if (type != ct_tar && type != ct_none)
|
||
FATAL_ERROR ((0, 0,
|