]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Use tuklib_mbstr_nonprint in a few more places
authorLasse Collin <lasse.collin@tukaani.org>
Tue, 26 May 2026 16:30:29 +0000 (19:30 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 27 May 2026 10:00:11 +0000 (13:00 +0300)
Reported-by: GitHub user curious-rabbit
src/xz/args.c
src/xz/coder.c
src/xz/util.c

index c32ee5c11159d63a74acfe7e3a46a3cf8f0a4a8b..bc7a5e8b02434b413907bf7cf1c0400a734ea1ac 100644 (file)
@@ -75,7 +75,8 @@ parse_block_list(const char *str_const)
 
        // It must be non-empty and not begin with a comma.
        if (str[0] == '\0' || str[0] == ',')
-               message_fatal(_("%s: Invalid argument to --block-list"), str);
+               message_fatal(_("%s: Invalid argument to --block-list"),
+                               tuklib_mask_nonprint(str));
 
        // Count the number of comma-separated strings.
        size_t count = 1;
@@ -86,7 +87,7 @@ parse_block_list(const char *str_const)
        // Prevent an unlikely integer overflow.
        if (count > SIZE_MAX / sizeof(block_list_entry) - 1)
                message_fatal(_("%s: Too many arguments to --block-list"),
-                               str);
+                               tuklib_mask_nonprint(str));
 
        // Allocate memory to hold all the sizes specified.
        // If --block-list was specified already, its value is forgotten.
@@ -562,7 +563,8 @@ parse_real(args_info *args, int argc, char **argv)
                                if (++i == ARRAY_SIZE(types))
                                        message_fatal(_("%s: Unknown file "
                                                        "format type"),
-                                                       optarg);
+                                                       tuklib_mask_nonprint(
+                                                               optarg));
 
                        opt_format = types[i].format;
                        break;
@@ -584,15 +586,16 @@ parse_real(args_info *args, int argc, char **argv)
                        while (strcmp(types[i].str, optarg) != 0) {
                                if (++i == ARRAY_SIZE(types))
                                        message_fatal(_("%s: Unsupported "
-                                                       "integrity "
-                                                       "check type"), optarg);
+                                               "integrity check type"),
+                                               tuklib_mask_nonprint(optarg));
                        }
 
                        // Use a separate check in case we are using different
                        // liblzma than what was used to compile us.
                        if (!lzma_check_is_supported(types[i].check))
-                               message_fatal(_("%s: Unsupported integrity "
-                                               "check type"), optarg);
+                               message_fatal(_("%s: Unsupported "
+                                               "integrity check type"),
+                                               tuklib_mask_nonprint(optarg));
 
                        coder_set_check(types[i].check);
                        break;
@@ -645,8 +648,9 @@ parse_real(args_info *args, int argc, char **argv)
                                        // TRANSLATORS: This is a translatable
                                        // string because French needs a space
                                        // before the colon ("%s : %s").
-                                       message_fatal(_("%s: %s"), optarg,
-                                                       strerror(errno));
+                                       message_fatal(_("%s: %s"),
+                                               tuklib_mask_nonprint(optarg),
+                                               strerror(errno));
                        }
 
                        break;
index c28f874a25f70ad2496fa72a7966ad1c8bd9c09a..92e35622a2c86fff4fbd23287162f78c53a31208 100644 (file)
@@ -172,7 +172,7 @@ str_to_filters(const char *str, uint32_t index, uint32_t flags)
                // the messages are included in xz's translations.
                message(V_ERROR, _("Error in --filters%s=FILTERS option:"),
                                filter_num);
-               message(V_ERROR, "%s", str);
+               message(V_ERROR, "%s", tuklib_mask_nonprint(str));
                message(V_ERROR, "%*s^", error_pos, "");
                message_fatal("%s", _(err));
        }
index bb9b86ad382cba07642e2476e506fa69bcaa3c99..06b774d0b5229ac88924b6bb3600482c40a790a8 100644 (file)
@@ -111,7 +111,7 @@ str_to_uint64(const char *name, const char *value, uint64_t min, uint64_t max)
                return max;
 
        if (*value < '0' || *value > '9')
-               message_fatal(_("%s: %s"), value,
+               message_fatal(_("%s: %s"), tuklib_mask_nonprint(value),
                        _("Value is not a non-negative decimal integer"));
 
        do {