diff --git a/usr.bin/tar/util.c b/usr.bin/tar/util.c index 858d472cba70..4177e9ce6447 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 e59f64704edb..838dffb45766 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; }