diff options
author | Matthias Klumpp <matthias@tenstral.net> | 2018-01-07 18:24:39 +0100 |
---|---|---|
committer | Matthias Klumpp <matthias@tenstral.net> | 2018-01-07 19:28:22 +0100 |
commit | 894ff1e62905abe03420bf510704e58a3b3f6e19 (patch) | |
tree | a0971c31b0433e8e026fb6dbc441aaf76cb96031 | |
parent | 0da6d891ac92c381461b75ee2b59fd7415bd8a8d (diff) | |
download | meson-894ff1e62905abe03420bf510704e58a3b3f6e19.zip meson-894ff1e62905abe03420bf510704e58a3b3f6e19.tar.gz meson-894ff1e62905abe03420bf510704e58a3b3f6e19.tar.bz2 |
Ensure subproject_dir is a string and doesn't contain ".." segments
This is important so people can not trick Meson to select a
subproject_dir that is not in the project's source directory.
It also ensures a string is used for the path.
-rw-r--r-- | mesonbuild/interpreter.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index f472910..48b8d82 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1883,10 +1883,14 @@ to directly access options of other subprojects.''') raise InvalidCode('Second call to project().') if not self.is_subproject() and 'subproject_dir' in kwargs: spdirname = kwargs['subproject_dir'] + if not isinstance(spdirname, str): + raise InterpreterException('Subproject_dir must be a string') if os.path.isabs(spdirname): raise InterpreterException('Subproject_dir must not be an absolute path.') if spdirname.startswith('.'): raise InterpreterException('Subproject_dir must not begin with a period.') + if '..' in spdirname: + raise InterpreterException('Subproject_dir must not contain a ".." segment.') self.subproject_dir = spdirname if 'meson_version' in kwargs: |