From: Michael Tremer Date: Fri, 9 Sep 2022 18:02:17 +0000 (+0000) Subject: file: Ensure that all desired digests are computed X-Git-Tag: 0.9.28~312 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4b2ef2d7f8b5b5c5c64fc71e36c1d0bf8c13b79;p=pakfire.git file: Ensure that all desired digests are computed Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index 16669504f..15c8e2765 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -272,6 +272,7 @@ ERROR: struct archive_entry* pakfire_file_archive_entry(struct pakfire_file* file, int digest_types) { const char* path = NULL; + int r; struct archive_entry* entry = archive_entry_new(); if (!entry) { @@ -310,6 +311,11 @@ struct archive_entry* pakfire_file_archive_entry(struct pakfire_file* file, int archive_entry_set_ctime(entry, pakfire_file_get_ctime(file), 0); archive_entry_set_mtime(entry, pakfire_file_get_mtime(file), 0); + // Compute any required file digests + r = pakfire_file_compute_digests(file, digest_types); + if (r) + goto ERROR; + // Copy digests // SHA-3-512 @@ -349,6 +355,12 @@ struct archive_entry* pakfire_file_archive_entry(struct pakfire_file* file, int file->digests.sha2_256, sizeof(file->digests.sha2_256)); return entry; + +ERROR: + if (entry) + archive_entry_free(entry); + + return NULL; } static void pakfire_file_free(struct pakfire_file* file) {