diff options
author | Tim Northover <tnorthover@apple.com> | 2015-11-09 22:05:05 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2015-11-09 22:05:05 +0000 |
commit | 974ff61c57322b6d419a3205a43e42b72671a080 (patch) | |
tree | 461c8799228ac7ac1d4e24bf9f6cc1234eaf84fc /lldb/packages/Python/lldbsuite/test/functionalities/process_launch | |
parent | 5b0ae794b6f039d69dc3e385442d8f058de6a278 (diff) | |
download | bcm5719-llvm-974ff61c57322b6d419a3205a43e42b72671a080.tar.gz bcm5719-llvm-974ff61c57322b6d419a3205a43e42b72671a080.zip |
Avoid sending bare '*' and '}' in an lldb-server packet
They get treated as special RLE encoding symbols and packets get
corrupted. Most other packet types already know about this apparently,
but QEnvironment missed these two.
Should fix PR25300.
llvm-svn: 252521
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/process_launch')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py | 21 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp | 11 |
2 files changed, 32 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py index bc1a6f75b87..9346bb0ba85 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py @@ -178,3 +178,24 @@ class ProcessLaunchTestCase(TestBase): if not success: self.fail(err_msg) + + def test_environment_with_special_char (self): + """Test that environment variables containing '*' and '}' are communicated correctly to the lldb-server.""" + d = {'CXX_SOURCES' : 'print_env.cpp'} + self.build(dictionary=d) + self.setTearDownCleanup(d) + exe = os.path.join (os.getcwd(), "a.out") + + evil_var = 'INIT*MIDDLE}TAIL' + + target = self.dbg.CreateTarget(exe) + process = target.LaunchSimple(None, ['EVIL=' + evil_var], self.get_process_working_directory()) + self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED) + + out = process.GetSTDOUT(len(evil_var))[:len(evil_var)] + if out != evil_var: + self.fail('The environment variable was mis-coded: %s\n' % repr(out)) + + newline = process.GetSTDOUT(1)[0] + if newline != '\r' and newline != '\n': + self.fail('Garbage at end of environment variable') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp new file mode 100644 index 00000000000..cbb9b217591 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +int main (int argc, char **argv) +{ + char *evil = getenv("EVIL"); + puts(evil); + + return 0; +} |