]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Merge pull request #2710 from meecash/CVE-2025-25724-check_strftime_result
authorMartin Matuška <martin@matuska.de>
Wed, 10 Sep 2025 08:22:58 +0000 (10:22 +0200)
committerMartin Matuska <martin@matuska.de>
Tue, 23 Sep 2025 20:59:15 +0000 (22:59 +0200)
Fix CVE-2025-25724 by checking the result of the strftime

(cherry picked from commit 6bd863f61281aecf2e78737b08838d4a27cf1fcb)

tar/util.c

index c99f67797562c515025eb38bbff498bf5ef5b684..5bad4345e24264d23258880b9649840c203a9be6 100644 (file)
@@ -682,6 +682,7 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
 {
        char                     tmp[100];
        size_t                   w;
+       size_t                   sw;
        const char              *p;
        const char              *fmt;
        time_t                   tim;
@@ -769,8 +770,8 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
        ltime = localtime(&tim);
 #endif
        if (ltime)
-               strftime(tmp, sizeof(tmp), fmt, ltime);
-       else
+               sw = strftime(tmp, sizeof(tmp), fmt, ltime);
+       if (!ltime || !sw)
                sprintf(tmp, "-- -- ----");
        fprintf(out, " %s ", tmp);
        safe_fprintf(out, "%s", archive_entry_pathname(entry));