From fcfaf9b7fc80fde4c341ef4c7b10a65be7c7b4ea Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 31 Dec 2024 18:19:21 +0000 Subject: [PATCH] util: Terminate pakfire_copy() even if feof() does not work Signed-off-by: Michael Tremer --- src/libpakfire/util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index 7af040c64..f461b4b37 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -618,14 +618,18 @@ int pakfire_copy(struct pakfire_ctx* ctx, FILE* src, FILE* dst) { // Check for any errors if (ferror(src)) { ERROR(ctx, "Could not read data: %m\n"); - return 1; + return -errno; } + // Break if we could not read anything + if (!bytes_read) + break; + // Write the data bytes_written = fwrite(buffer, 1, bytes_read, dst); if (bytes_written < bytes_read) { ERROR(ctx, "Could not write data: %m\n"); - return 1; + return -errno; } } -- 2.47.3