summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_write_set_format_pax.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-11-05 05:26:30 +0000
committerkientzle <kientzle@FreeBSD.org>2004-11-05 05:26:30 +0000
commitfef2e8cee8e209e7511da1d45f988dd029197358 (patch)
treebbc8fe472af0e8dbd66e73826de4bcb674aab1ff /lib/libarchive/archive_write_set_format_pax.c
parent0a60201e3c56d5679ba25dbcc969368ba3fb74ea (diff)
downloadFreeBSD-src-fef2e8cee8e209e7511da1d45f988dd029197358.zip
FreeBSD-src-fef2e8cee8e209e7511da1d45f988dd029197358.tar.gz
Clean up the error handling in the
write path. In particular, this should solve some problems people have seen with bsdtar not exiting on various write errors.
Diffstat (limited to 'lib/libarchive/archive_write_set_format_pax.c')
-rw-r--r--lib/libarchive/archive_write_set_format_pax.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/libarchive/archive_write_set_format_pax.c b/lib/libarchive/archive_write_set_format_pax.c
index 7987e08..a4e4f2a 100644
--- a/lib/libarchive/archive_write_set_format_pax.c
+++ b/lib/libarchive/archive_write_set_format_pax.c
@@ -622,7 +622,7 @@ archive_write_pax_header(struct archive *a,
__archive_write_format_header_ustar(a, ustarbuff, entry_main, -1, 0);
/* If we built any extended attributes, write that entry first. */
- ret = 0;
+ ret = ARCHIVE_OK;
if (archive_strlen(&(pax->pax_header)) > 0) {
struct stat st;
struct archive_entry *pax_attr_entry;
@@ -663,7 +663,7 @@ archive_write_pax_header(struct archive *a,
exit(1);
}
r = (a->compression_write)(a, paxbuff, 512);
- if (r < 512) {
+ if (r != ARCHIVE_OK) {
pax->entry_bytes_remaining = 0;
pax->entry_padding = 0;
return (ARCHIVE_FATAL);
@@ -677,7 +677,7 @@ archive_write_pax_header(struct archive *a,
r = archive_write_data(a, pax->pax_header.s,
archive_strlen(&(pax->pax_header)));
a->state = oldstate;
- if (r < (int)archive_strlen(&(pax->pax_header))) {
+ if (r != ARCHIVE_OK) {
/* If a write fails, we're pretty much toast. */
return (ARCHIVE_FATAL);
}
@@ -687,8 +687,8 @@ archive_write_pax_header(struct archive *a,
/* Write the header for main entry. */
r = (a->compression_write)(a, ustarbuff, 512);
- if (ret != ARCHIVE_OK)
- ret = (r < 512) ? ARCHIVE_FATAL : ARCHIVE_OK;
+ if (r != ARCHIVE_OK)
+ return (r);
/*
* Inform the client of the on-disk size we're using, so
@@ -839,9 +839,9 @@ write_nulls(struct archive *a, size_t padding)
while (padding > 0) {
to_write = padding < a->null_length ? padding : a->null_length;
ret = (a->compression_write)(a, a->nulls, to_write);
- if (ret <= 0)
- return (ARCHIVE_FATAL);
- padding -= ret;
+ if (ret != ARCHIVE_OK)
+ return (ret);
+ padding -= to_write;
}
return (ARCHIVE_OK);
}
OpenPOWER on IntegriCloud