Skip to content

Commit

Permalink
Merge pull request NixOS#8825 from trofi/search-path-prefix
Browse files Browse the repository at this point in the history
src/libexpr/search-path.cc: avoid out-of-bounds read on string_view
  • Loading branch information
edolstra authored Aug 16, 2023
2 parents 5542c1f + b74962c commit 7f8c99c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libexpr/search-path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7f8c99c

Please sign in to comment.