]> git.ipfire.org Git - pakfire.git/commitdiff
archive: Check whether we are trying to open an empty file
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Sep 2022 16:29:34 +0000 (16:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Sep 2022 16:29:34 +0000 (16:29 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/archive.c

index 62499943b89cdf30a448b9bed3155fd7a8a9a50e..799eda75bdb05353b9cd84e28c720ab60baafdd4 100644 (file)
@@ -566,6 +566,13 @@ static int __pakfire_archive_filter_metadata(struct pakfire* pakfire,
 static int pakfire_archive_read_metadata(struct pakfire_archive* archive) {
        int r;
 
+       // Check if the archive file actually has any contect
+       if (!archive->stat.st_size) {
+               ERROR(archive->pakfire, "Trying to open an empty archive file\n");
+               errno = EINVAL;
+               return 1;
+       }
+
        DEBUG(archive->pakfire, "Reading archive metadata...\n");
 
        // Walk through the archive