1
0
mirror of https://git.tukaani.org/xz.git synced 2026-10-31 11:24:56 +00:00

xz: Use tuklib_mbstr_nonprint in a few more places

Reported-by: GitHub user curious-rabbit
This commit is contained in:
Lasse Collin 2026-05-26 19:30:29 +03:00
parent 1df00237ae
commit 7e7bb6c21c
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
3 changed files with 15 additions and 11 deletions

View File

@ -75,7 +75,8 @@ parse_block_list(const char *str_const)
// It must be non-empty and not begin with a comma. // It must be non-empty and not begin with a comma.
if (str[0] == '\0' || str[0] == ',') 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. // Count the number of comma-separated strings.
size_t count = 1; size_t count = 1;
@ -86,7 +87,7 @@ parse_block_list(const char *str_const)
// Prevent an unlikely integer overflow. // Prevent an unlikely integer overflow.
if (count > SIZE_MAX / sizeof(block_list_entry) - 1) if (count > SIZE_MAX / sizeof(block_list_entry) - 1)
message_fatal(_("%s: Too many arguments to --block-list"), message_fatal(_("%s: Too many arguments to --block-list"),
str); tuklib_mask_nonprint(str));
// Allocate memory to hold all the sizes specified. // Allocate memory to hold all the sizes specified.
// If --block-list was specified already, its value is forgotten. // 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)) if (++i == ARRAY_SIZE(types))
message_fatal(_("%s: Unknown file " message_fatal(_("%s: Unknown file "
"format type"), "format type"),
optarg); tuklib_mask_nonprint(
optarg));
opt_format = types[i].format; opt_format = types[i].format;
break; break;
@ -584,15 +586,16 @@ parse_real(args_info *args, int argc, char **argv)
while (strcmp(types[i].str, optarg) != 0) { while (strcmp(types[i].str, optarg) != 0) {
if (++i == ARRAY_SIZE(types)) if (++i == ARRAY_SIZE(types))
message_fatal(_("%s: Unsupported " message_fatal(_("%s: Unsupported "
"integrity " "integrity check type"),
"check type"), optarg); tuklib_mask_nonprint(optarg));
} }
// Use a separate check in case we are using different // Use a separate check in case we are using different
// liblzma than what was used to compile us. // liblzma than what was used to compile us.
if (!lzma_check_is_supported(types[i].check)) if (!lzma_check_is_supported(types[i].check))
message_fatal(_("%s: Unsupported integrity " message_fatal(_("%s: Unsupported "
"check type"), optarg); "integrity check type"),
tuklib_mask_nonprint(optarg));
coder_set_check(types[i].check); coder_set_check(types[i].check);
break; break;
@ -645,8 +648,9 @@ parse_real(args_info *args, int argc, char **argv)
// TRANSLATORS: This is a translatable // TRANSLATORS: This is a translatable
// string because French needs a space // string because French needs a space
// before the colon ("%s : %s"). // before the colon ("%s : %s").
message_fatal(_("%s: %s"), optarg, message_fatal(_("%s: %s"),
strerror(errno)); tuklib_mask_nonprint(optarg),
strerror(errno));
} }
break; break;

View 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. // the messages are included in xz's translations.
message(V_ERROR, _("Error in --filters%s=FILTERS option:"), message(V_ERROR, _("Error in --filters%s=FILTERS option:"),
filter_num); filter_num);
message(V_ERROR, "%s", str); message(V_ERROR, "%s", tuklib_mask_nonprint(str));
message(V_ERROR, "%*s^", error_pos, ""); message(V_ERROR, "%*s^", error_pos, "");
message_fatal("%s", _(err)); message_fatal("%s", _(err));
} }

View File

@ -111,7 +111,7 @@ str_to_uint64(const char *name, const char *value, uint64_t min, uint64_t max)
return max; return max;
if (*value < '0' || *value > '9') 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")); _("Value is not a non-negative decimal integer"));
do { do {