From 84e3786e05bb8cda52548b8d98efe87f2a1b64ac Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Tue, 21 Jul 2009 13:49:35 +0300 Subject: db: fixes to package checksumming while installing it --- src/archive.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/archive.c') diff --git a/src/archive.c b/src/archive.c index b069f2d..7c26502 100644 --- a/src/archive.c +++ b/src/archive.c @@ -129,10 +129,8 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, while ((r = is->read(is, &buf, 512)) == 512) { offset += 512; if (buf.name[0] == '\0') { - if (end) { - r = 0; - //break; - } + if (end) + break; end++; continue; } @@ -218,11 +216,18 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, } EVP_MD_CTX_cleanup(&teis.mdctx); - if (r != 0) { - apk_error("Bad TAR header (r=%d)", r); - return -1; + /* Read remaining end-of-archive records, to ensure we read all of + * the file. The underlying istream is likely doing checksumming. */ + if (r == 512) { + while ((r = is->read(is, &buf, 512)) == 512) + if (buf.name[0] != 0) + return -1; } + /* Check that there was no partial record */ + if (r != 0) + return -1; + return 0; err: -- cgit v1.2.3-60-g2f50