]> git.ipfire.org Git - pakfire.git/commitdiff
archive: Ensure r is always set correctly
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 12 Jan 2025 11:26:41 +0000 (11:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 12 Jan 2025 11:26:41 +0000 (11:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/archive.c

index 5169c07744dfed837b4a8bf7472f80a735500ad4..4c76fcd15764f573e8f2fb9c09bb03193cc1abd8 100644 (file)
@@ -167,18 +167,25 @@ static int archive_read_file_open(struct archive* a, FILE* f) {
        // Reset so we won't accidentally close it
        f = NULL;
 
-       if (fd < 0)
+       if (fd < 0) {
+               r = -EBADF;
                goto ERROR;
+       }
 
        // Duplicate the file descriptor
        fd = dup(fd);
-       if (fd < 0)
+       if (fd < 0) {
+               r = -errno;
                goto ERROR;
+       }
+
 
        // Re-open the file handle
        f = fdopen(fd, "r");
-       if (!f)
+       if (!f) {
+               r = -errno;
                goto ERROR;
+       }
 
        // Reset file descriptor
        fd = -EBADF;