aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2017-05-23 18:34:43 +0300
committerLasse Collin <lasse.collin@tukaani.org>2018-03-28 19:16:06 +0300
commiteb2ef4c79bf405ea0d215f3b1df3d0eaf5e1d27b (patch)
tree3fc1431ae1c8c35ce6cd025c331f46cc2ec75473
parentBuild: Omit pre-5.0.0 entries from the generated ChangeLog. (diff)
downloadxz-eb2ef4c79bf405ea0d215f3b1df3d0eaf5e1d27b.tar.xz
xz: Fix "xz --list --robot missing_or_bad_file.xz".
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.
-rw-r--r--src/xz/list.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/xz/list.c b/src/xz/list.c
index 449c2bc4..4dd1f6f8 100644
--- a/src/xz/list.c
+++ b/src/xz/list.c
@@ -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.
@@ -636,7 +636,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;