summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8e1fbe4)
We should never see an EOF from the underlying I/O when reading archive
members, because we setup the read request to only return bytes that are
supposed to be there.
So if EOF happens, flag this as an error and do *not* set the eof flag
in the state structure. Also fixup lbxtool to properly handle this.
rc = fops->read(buf, want, f->lbx->f);
f->offset += rc;
rc = fops->read(buf, want, f->lbx->f);
f->offset += rc;
- if (want < n || (rc < want && fops->eof(f->lbx->f)))
+ if (rc < want) {
+ if (fops->eof(f->lbx->f))
+ lbx_error_raise(LBX_EEOF);
+ } else if (rc < n) {
unsigned char buf[1024];
rc = lbx_file_read(f, buf, sizeof buf);
unsigned char buf[1024];
rc = lbx_file_read(f, buf, sizeof buf);
- if (rc == 0) {
- if (lbx_file_eof(f))
- ret = 0;
- break;
- }
-
- if (fwrite(buf, rc, 1, of) != 1) {
- tool_err(0, "%s: fwrite", stat->name);
- break;
+ if (rc > 0) {
+ /* Write out any data we got. */
+ if (fwrite(buf, rc, 1, of) != 1) {
+ tool_err(0, "%s: fwrite", stat->name);
+ break;
+ }
+ /* Now test for read errors */
+ if (!lbx_file_eof(f))
+ tool_err(-1, "error reading archive: %s", lbx_errmsg());
+ else
failed=false
$LBXTOOL -xf "$testdata/arch-trunc.lbx" || failed=true
failed=false
$LBXTOOL -xf "$testdata/arch-trunc.lbx" || failed=true
-command_ok_ "EOF handled in archive" -D TODO $failed
+command_ok_ "EOF handled in archive" $failed