diff options
author | Timo Teräs <timo.teras@iki.fi> | 2018-10-26 08:21:52 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2018-10-26 08:22:08 +0300 |
commit | beab8545ebb2898a2beb157a4d9424ebddf3e26f (patch) | |
tree | c85cc3d47cde7f8a1a368f4f7bfad6ccac3b1015 /src/archive.c | |
parent | 40ffdfe623c73c3fdba15fd24bd05d206eff7aad (diff) | |
download | apk-tools-beab8545ebb2898a2beb157a4d9424ebddf3e26f.tar.gz apk-tools-beab8545ebb2898a2beb157a4d9424ebddf3e26f.tar.bz2 apk-tools-beab8545ebb2898a2beb157a4d9424ebddf3e26f.tar.xz apk-tools-beab8545ebb2898a2beb157a4d9424ebddf3e26f.zip |
add support for openssl 1.1
Diffstat (limited to 'src/archive.c')
-rw-r--r-- | src/archive.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/archive.c b/src/archive.c index 9a184fd..f3a66c2 100644 --- a/src/archive.c +++ b/src/archive.c @@ -28,6 +28,7 @@ #include "apk_defines.h" #include "apk_print.h" #include "apk_archive.h" +#include "apk_openssl.h" struct tar_header { /* ustar header, Posix 1003.1 */ @@ -82,7 +83,7 @@ struct apk_tar_entry_istream { struct apk_istream is; struct apk_istream *tar_is; size_t bytes_left; - EVP_MD_CTX mdctx; + EVP_MD_CTX *mdctx; struct apk_checksum *csum; time_t mtime; }; @@ -121,10 +122,10 @@ static ssize_t tar_entry_read(void *stream, void *ptr, size_t size) if (teis->csum == NULL) return r; - EVP_DigestUpdate(&teis->mdctx, ptr, r); + EVP_DigestUpdate(teis->mdctx, ptr, r); if (teis->bytes_left == 0) { - teis->csum->type = EVP_MD_CTX_size(&teis->mdctx); - EVP_DigestFinal_ex(&teis->mdctx, teis->csum->data, NULL); + teis->csum->type = EVP_MD_CTX_size(teis->mdctx); + EVP_DigestFinal_ex(teis->mdctx, teis->csum->data, NULL); } return r; } @@ -210,7 +211,9 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, char filename[sizeof buf.name + sizeof buf.prefix + 2]; odi = (struct apk_tar_digest_info *) &buf.linkname[3]; - EVP_MD_CTX_init(&teis.mdctx); + teis.mdctx = EVP_MD_CTX_new(); + if (!teis.mdctx) return -ENOMEM; + memset(&entry, 0, sizeof(entry)); entry.name = buf.name; while ((r = apk_istream_read(is, &buf, 512)) == 512) { @@ -327,7 +330,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, if (entry.mode & S_IFMT) { /* callback parser function */ if (teis.csum != NULL) - EVP_DigestInit_ex(&teis.mdctx, + EVP_DigestInit_ex(teis.mdctx, apk_checksum_default(), NULL); r = parser(ctx, &entry, &teis.is); @@ -360,7 +363,7 @@ err: /* Check that there was no partial (or non-zero) record */ if (r >= 0) r = -EBADMSG; ok: - EVP_MD_CTX_cleanup(&teis.mdctx); + EVP_MD_CTX_free(teis.mdctx); free(pax.ptr); free(longname.ptr); apk_fileinfo_free(&entry); |