diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-07-21 13:49:35 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-07-21 13:49:35 +0300 |
commit | 84e3786e05bb8cda52548b8d98efe87f2a1b64ac (patch) | |
tree | 56d453d243f809e8daac40b932c097fa04cc8aa2 /src/archive.c | |
parent | be8b59dbe1525a5885bbe3737aa696a01004d633 (diff) | |
download | apk-tools-84e3786e05bb8cda52548b8d98efe87f2a1b64ac.tar.gz apk-tools-84e3786e05bb8cda52548b8d98efe87f2a1b64ac.tar.bz2 apk-tools-84e3786e05bb8cda52548b8d98efe87f2a1b64ac.tar.xz apk-tools-84e3786e05bb8cda52548b8d98efe87f2a1b64ac.zip |
db: fixes to package checksumming while installing it
Diffstat (limited to 'src/archive.c')
-rw-r--r-- | src/archive.c | 19 |
1 files changed, 12 insertions, 7 deletions
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: |