]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
i should be size_t (#2575)
authorAZero13 <gfunni234@gmail.com>
Fri, 11 Apr 2025 03:14:55 +0000 (23:14 -0400)
committerGitHub <noreply@github.com>
Fri, 11 Apr 2025 03:14:55 +0000 (20:14 -0700)
The size of i does not matter, and a size_t is added to it, so to avoid
that truncation, just make i size_t. It also is passed as a size_t.

tar/util.c

index e467008210ebe4c7337142643b77baabed9b3b75..a63883527d0b452c8725276628a6be18d255200e 100644 (file)
@@ -82,7 +82,7 @@ safe_fprintf(FILE *f, const char *fmt, ...)
        int length, n;
        va_list ap;
        const char *p;
-       unsigned i;
+       size_t i;
        wchar_t wc;
        char try_wc;
 
@@ -153,13 +153,13 @@ safe_fprintf(FILE *f, const char *fmt, ...)
                        } else {
                                /* Not printable, format the bytes. */
                                while (n-- > 0)
-                                       i += (unsigned)bsdtar_expand_char(
+                                       i += bsdtar_expand_char(
                                            outbuff, sizeof(outbuff), i, *p++);
                        }
                } else {
                        /* After any conversion failure, don't bother
                         * trying to convert the rest. */
-                       i += (unsigned)bsdtar_expand_char(outbuff, sizeof(outbuff), i, *p++);
+                       i += bsdtar_expand_char(outbuff, sizeof(outbuff), i, *p++);
                        try_wc = 0;
                }