]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix CVE-2025-25724 by checking the result of the strftime 2710/head
authorMarcin Mikula <marcin@helix.pl>
Wed, 30 Jul 2025 08:29:12 +0000 (10:29 +0200)
committerMarcin Mikula <marcin@helix.pl>
Wed, 30 Jul 2025 08:33:51 +0000 (10:33 +0200)
to avoid use of undefined content of buf, in case when custom
locale makes the result string longer than buf length.

Signed-off-by: Marcin Mikula <marcin@helix.pl>
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));