]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Fix "xz --list --robot missing_or_bad_file.xz".
authorLasse Collin <lasse.collin@tukaani.org>
Tue, 23 May 2017 15:34:43 +0000 (18:34 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 23 May 2017 15:34:43 +0000 (18:34 +0300)
It ended up printing an uninitialized char-array when trying to
print the check names (column 7) on the "totals" line.

This also changes the column 12 (minimum xz version) to
50000002 (xz 5.0.0) instead of 0 when there are no valid
input files.

Thanks to kidmin for the bug report.

src/xz/list.c

index c297d2e3fd1577258b43b8b1a305451ec6d1a9be..bf462957148a12be27cdbc9022da7d259b4d4f74 100644 (file)
@@ -109,7 +109,7 @@ static struct {
        uint32_t checks;
        uint32_t min_version;
        bool all_have_sizes;
-} totals = { 0, 0, 0, 0, 0, 0, 0, 0, 0, true };
+} totals = { 0, 0, 0, 0, 0, 0, 0, 0, 50000002, true };
 
 
 /// Convert XZ Utils version number to a string.
@@ -470,7 +470,11 @@ static void
 get_check_names(char buf[CHECKS_STR_SIZE],
                uint32_t checks, bool space_after_comma)
 {
-       assert(checks != 0);
+       // If we get called when there are no Checks to print, set checks
+       // to 1 so that we print "None". This can happen in the robot mode
+       // when printing the totals line if there are no valid input files.
+       if (checks == 0)
+               checks = 1;
 
        char *pos = buf;
        size_t left = CHECKS_STR_SIZE;