Skip to content
Snippets Groups Projects
Commit 3a045c698115 authored by Lasse Collin's avatar Lasse Collin
Browse files

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.
parent af1896ba1fe8
No related branches found
No related tags found
No related merge requests found
......@@ -465,13 +465,9 @@
// NOTE: It's possible that name[0] is now '\0' if argv[0]
// is weird, but it doesn't matter here.
// If the command name contains "lz",
// it implies --format=lzma.
if (strstr(name, "lz") != NULL)
opt_format = FORMAT_LZMA;
// Operation mode
if (strstr(name, "cat") != NULL) {
// Imply --decompress --stdout
// Look for full command names instead of substrings like
// "un", "cat", and "lz" to reduce possibility of false
// positives when the programs have been renamed.
if (strstr(name, "xzcat") != NULL) {
opt_mode = MODE_DECOMPRESS;
opt_stdout = true;
......@@ -476,5 +472,7 @@
opt_mode = MODE_DECOMPRESS;
opt_stdout = true;
} else if (strstr(name, "un") != NULL) {
// Imply --decompress
} else if (strstr(name, "unxz") != NULL) {
opt_mode = MODE_DECOMPRESS;
} else if (strstr(name, "lzcat") != NULL) {
opt_format = FORMAT_LZMA;
opt_mode = MODE_DECOMPRESS;
......@@ -480,4 +478,10 @@
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;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment