summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2011-06-25 16:27:49 +0000
committerkientzle <kientzle@FreeBSD.org>2011-06-25 16:27:49 +0000
commitd717d950fa88ca5ea6d288d7a789bfd1b1709559 (patch)
treea7a845d35e086fe49a9288d7a22b3ec4dae422cd /usr.bin
parent1b609861c85e0538ad16d32d01c4bddc805df628 (diff)
downloadFreeBSD-src-d717d950fa88ca5ea6d288d7a789bfd1b1709559.zip
FreeBSD-src-d717d950fa88ca5ea6d288d7a789bfd1b1709559.tar.gz
If there is a read error reading Y/N confirmation from the keyboard,
exit immediately with an error. If there is an error opening or reading a file to put into the archive, set the return value for a deferred error exit. PR: bin/154407
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tar/util.c6
-rw-r--r--usr.bin/tar/write.c7
2 files changed, 12 insertions, 1 deletions
diff --git a/usr.bin/tar/util.c b/usr.bin/tar/util.c
index 858d472..4177e9c 100644
--- a/usr.bin/tar/util.c
+++ b/usr.bin/tar/util.c
@@ -226,7 +226,11 @@ yes(const char *fmt, ...)
fflush(stderr);
l = read(2, buff, sizeof(buff) - 1);
- if (l <= 0)
+ if (l < 0) {
+ fprintf(stderr, "Keyboard read failed\n");
+ exit(1);
+ }
+ if (l == 0)
return (0);
buff[l] = 0;
diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c
index e59f647..838dffb 100644
--- a/usr.bin/tar/write.c
+++ b/usr.bin/tar/write.c
@@ -919,6 +919,7 @@ write_entry_backend(struct bsdtar *bsdtar, struct archive *a,
const char *pathname = archive_entry_sourcepath(entry);
fd = open(pathname, O_RDONLY | O_BINARY);
if (fd == -1) {
+ bsdtar->return_value = 1;
if (!bsdtar->verbose)
bsdtar_warnc(errno,
"%s: could not open file", pathname);
@@ -1020,6 +1021,12 @@ write_file_data(struct bsdtar *bsdtar, struct archive *a,
progress += bytes_written;
bytes_read = read(fd, bsdtar->buff, FILEDATABUFLEN);
}
+ if (bytes_read < 0) {
+ bsdtar_warnc(errno,
+ "%s: Read error",
+ archive_entry_pathname(entry));
+ bsdtar->return_value = 1;
+ }
return 0;
}
OpenPOWER on IntegriCloud