diff options
author | Scott Graham <scottmg@chromium.org> | 2014-11-10 22:48:55 (GMT) |
---|---|---|
committer | Scott Graham <scottmg@chromium.org> | 2014-11-10 22:48:55 (GMT) |
commit | aece8b098cb2a5d722edf0221dfd0744a818a8d1 (patch) | |
tree | 13111e176ac8334654ab4ce5826ebe6b828ffa6d /src/util.cc | |
parent | 7d60548d7bafc7374d6486a5a6b350b4b4a2fa29 (diff) | |
download | Ninja-aece8b098cb2a5d722edf0221dfd0744a818a8d1.zip Ninja-aece8b098cb2a5d722edf0221dfd0744a818a8d1.tar.gz Ninja-aece8b098cb2a5d722edf0221dfd0744a818a8d1.tar.bz2 |
fix CanonicalizePath going past StringPiece length + test
Diffstat (limited to 'src/util.cc')
-rw-r--r-- | src/util.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc index eaf720f..f89c7ad 100644 --- a/src/util.cc +++ b/src/util.cc @@ -129,6 +129,8 @@ bool CanonicalizePath(char* path, size_t* len, unsigned int* slash_bits, unsigned int bits = 0; int bits_offset = 0; for (char* c = path; (c = strpbrk(c, "/\\")) != NULL;) { + if (static_cast<size_t>(c - path) >= *len) + break; bits |= (*c == '\\') << bits_offset; *c++ = '/'; bits_offset++; |