Correct error handling on failed writes

to the archive.
This commit is contained in:
Tim Kientzle 2004-11-05 05:39:37 +00:00
parent b772d06c77
commit f52188fc8a
2 changed files with 3 additions and 5 deletions

View File

@ -6,7 +6,7 @@
#
PROG= bsdtar
VERSION= 1.01.011
VERSION= 1.01.015
SRCS= bsdtar.c matching.c read.c util.c write.c
WARNS?= 6
DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ}

View File

@ -875,10 +875,8 @@ write_file_data(struct bsdtar *bsdtar, struct archive *a, int fd)
bytes_read = read(fd, buff, sizeof(buff));
while (bytes_read > 0) {
bytes_written = archive_write_data(a, buff, bytes_read);
if (bytes_written == 0 && errno) {
return -1; /* Write failed; this is bad */
}
if (bytes_written <= 0)
return (-1); /* Write failed; this is bad */
bytes_read = read(fd, buff, sizeof(buff));
}
return 0;