]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Fix minor integer overflow in xsparse.c
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 8 Aug 2024 23:38:28 +0000 (16:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 15 Aug 2024 06:25:46 +0000 (23:25 -0700)
* scripts/xsparse.c (read_xheader):
Don’t assume size_t fits in unsigned.
Make the version numbers off_t, not just unsigned.

scripts/xsparse.c

index a6c36602c2ec1e2e28fbd4dcc4dbb430df255124..625b04d9dc680017000d7807fb266172d4d35201 100644 (file)
@@ -160,8 +160,8 @@ get_var (FILE *fp, char **name, char **value)
 
 static char *outname;
 static off_t outsize;
-static unsigned int version_major;
-static unsigned int version_minor;
+static off_t version_major;
+static off_t version_minor;
 
 static void
 read_xheader (char *name)
@@ -190,11 +190,11 @@ read_xheader (char *name)
        }
       else if (strcmp (kw, "major") == 0)
        {
-         version_major = string_to_size (val, NULL, SIZE_MAX);
+         version_major = string_to_off (val, NULL);
        }
       else if (strcmp (kw, "minor") == 0)
        {
-         version_minor = string_to_size (val, NULL, SIZE_MAX);
+         version_minor = string_to_off (val, NULL);
        }
       else if (strcmp (kw, "realsize") == 0
               || strcmp (kw, "size") == 0)