diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c index 26e59f3be0d2..22290c9906cd 100644 --- a/usr.bin/tar/write.c +++ b/usr.bin/tar/write.c @@ -404,7 +404,10 @@ write_archive(struct archive *a, struct bsdtar *bsdtar) } create_cleanup(bsdtar); - archive_write_close(a); + if (archive_write_close(a)) { + bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a)); + bsdtar->return_value = 1; + } } /* @@ -789,7 +792,8 @@ write_entry(struct bsdtar *bsdtar, struct archive *a, const struct stat *st, * that case, just skip the write. */ if (fd >= 0 && archive_entry_size(entry) > 0) - write_file_data(bsdtar, a, fd); + if (write_file_data(bsdtar, a, fd)) + exit(1); cleanup: if (bsdtar->verbose) @@ -814,13 +818,15 @@ write_file_data(struct bsdtar *bsdtar, struct archive *a, int fd) /* XXX TODO: Allocate buffer on heap and store pointer to * it in bsdtar structure; arrange cleanup as well. XXX */ - (void)bsdtar; bytes_read = read(fd, buff, sizeof(buff)); while (bytes_read > 0) { bytes_written = archive_write_data(a, buff, bytes_read); - if (bytes_written <= 0) - return (-1); /* Write failed; this is bad */ + if (bytes_written <= 0) { + /* Write failed; this is bad */ + bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a)); + return (-1); + } bytes_read = read(fd, buff, sizeof(buff)); } return 0;