diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2023-08-16 16:44:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-16 16:44:49 +0200 |
commit | 7f8c99c70c96bf3685e5cad73b38ede801079177 (patch) | |
tree | 0e828d6b01af8901e2ce42e56011e40d53aef46d | |
parent | 5542c1f87ee3325bce8140f4087b12647b4107ef (diff) | |
parent | b74962c92b2d8d9b957934e0aefcf4983169ae1e (diff) |
Merge pull request #8825 from trofi/search-path-prefix
src/libexpr/search-path.cc: avoid out-of-bounds read on string_view
-rw-r--r-- | src/libexpr/search-path.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libexpr/search-path.cc b/src/libexpr/search-path.cc index 36bb4c3a5..180d5f8b1 100644 --- a/src/libexpr/search-path.cc +++ b/src/libexpr/search-path.cc @@ -10,7 +10,7 @@ std::optional<std::string_view> SearchPath::Prefix::suffixIfPotentialMatch( /* Non-empty prefix and suffix must be separated by a /, or the prefix is not a valid path prefix. */ - bool needSeparator = n > 0 && (path.size() - n) > 0; + bool needSeparator = n > 0 && n < path.size(); if (needSeparator && path[n] != '/') { return std::nullopt; |