diff options
| -rw-r--r-- | apt-private/private-output.cc | 12 | ||||
| -rwxr-xr-x | test/integration/test-apt-cli-pager | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index 4480d7382..a1105be61 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -160,7 +160,17 @@ bool InitOutputPager() signal(sig, SIG_DFL); for (auto &v: pagerEnv) - putenv(v.data()); + { + // WARNING: VectorizeString() is not thread-safe, do not call after creating a thread. + auto keyAndValue = VectorizeString(v, '='); + if (keyAndValue.size() != 2) + { + _error->Fatal("Invalid environment string: %s", v.c_str()); + goto err; + } + // NOTE: Must not override user values, so setenv(..., override=0) is used rather than putenv() + setenv(keyAndValue[0].c_str(), keyAndValue[1].c_str(), 0); + } { // If our pager name contains a space we need to invoke it in a shell. Boooo! diff --git a/test/integration/test-apt-cli-pager b/test/integration/test-apt-cli-pager index d1f8c3288..cc220c81f 100755 --- a/test/integration/test-apt-cli-pager +++ b/test/integration/test-apt-cli-pager @@ -125,3 +125,6 @@ Checksums-Sha256: PAGER="head -2" testsuccessequal "Package: foo Binary: foo" runapt --unbuffer apt showsrc foo -o TestPager="head- 2" + +PAGER='echo $LESS' testsuccessequal "FRX" runapt --unbuffer apt showsrc foo -o TestPager='echo $LESS (1)' +LESS=FRXM PAGER='echo $LESS' testsuccessequal "FRXM" runapt --unbuffer apt showsrc foo -o TestPager='echo $LESS (2)' |
