]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Avoid reading outside input in expand_environment_variables
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 9 Aug 2020 20:24:24 +0000 (22:24 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 9 Aug 2020 20:38:34 +0000 (22:38 +0200)
The edge case of an input “$” without a following variable name was not
ported correctly in ab3c68b266d0d2d24c46dd1ef32e74e35ec388d6.

src/Util.cpp

index d3ac33cdf39f32e74ede5f7ca531f2a4cad31f8c..f1591a27a77f204929406bc5a69cf94f8566d07d 100644 (file)
@@ -392,6 +392,7 @@ expand_environment_variables(const std::string& str)
       if (right == left) {
         // Special case: don't consider a single $ the left of a variable.
         result += '$';
+        --right;
       } else {
         std::string name(left, right - left);
         const char* value = getenv(name.c_str());