Look for full command names instead of substrings
like "un", "cat", and "lz" when determining if xz is run as unxz, xzcat, lzma, unlzma, or lzcat. This is to ensure that if xz is renamed (e.g. via --program-transform-name), it doesn't so easily work in wrong mode.
This commit is contained in:
parent
6f62fa88f4
commit
eed9953732
|
@ -465,19 +465,23 @@ args_parse(args_info *args, int argc, char **argv)
|
||||||
// NOTE: It's possible that name[0] is now '\0' if argv[0]
|
// NOTE: It's possible that name[0] is now '\0' if argv[0]
|
||||||
// is weird, but it doesn't matter here.
|
// is weird, but it doesn't matter here.
|
||||||
|
|
||||||
// If the command name contains "lz",
|
// Look for full command names instead of substrings like
|
||||||
// it implies --format=lzma.
|
// "un", "cat", and "lz" to reduce possibility of false
|
||||||
if (strstr(name, "lz") != NULL)
|
// positives when the programs have been renamed.
|
||||||
opt_format = FORMAT_LZMA;
|
if (strstr(name, "xzcat") != NULL) {
|
||||||
|
|
||||||
// Operation mode
|
|
||||||
if (strstr(name, "cat") != NULL) {
|
|
||||||
// Imply --decompress --stdout
|
|
||||||
opt_mode = MODE_DECOMPRESS;
|
opt_mode = MODE_DECOMPRESS;
|
||||||
opt_stdout = true;
|
opt_stdout = true;
|
||||||
} else if (strstr(name, "un") != NULL) {
|
} else if (strstr(name, "unxz") != NULL) {
|
||||||
// Imply --decompress
|
|
||||||
opt_mode = MODE_DECOMPRESS;
|
opt_mode = MODE_DECOMPRESS;
|
||||||
|
} else if (strstr(name, "lzcat") != NULL) {
|
||||||
|
opt_format = FORMAT_LZMA;
|
||||||
|
opt_mode = MODE_DECOMPRESS;
|
||||||
|
opt_stdout = true;
|
||||||
|
} else if (strstr(name, "unlzma") != NULL) {
|
||||||
|
opt_format = FORMAT_LZMA;
|
||||||
|
opt_mode = MODE_DECOMPRESS;
|
||||||
|
} else if (strstr(name, "lzma") != NULL) {
|
||||||
|
opt_format = FORMAT_LZMA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue