From: Michael Tremer Date: Tue, 31 Dec 2024 18:19:21 +0000 (+0000) Subject: util: Terminate pakfire_copy() even if feof() does not work X-Git-Tag: 0.9.30~619 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fcfaf9b7fc80fde4c341ef4c7b10a65be7c7b4ea;p=pakfire.git util: Terminate pakfire_copy() even if feof() does not work Signed-off-by: Michael Tremer --- 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; } }