diff options
author | Scott Graham <scottmg@chromium.org> | 2015-06-08 20:21:55 (GMT) |
---|---|---|
committer | Scott Graham <scottmg@chromium.org> | 2015-06-08 20:21:55 (GMT) |
commit | a2d1cf2f26bdd7a326a3ef6186ee507fd87868d0 (patch) | |
tree | 4792697f4e5c73661991ca1b90b919ff3a60c15c /src/includes_normalize_test.cc | |
parent | f0f36ad1c72f6100a8957f035769fda50b69919f (diff) | |
download | Ninja-a2d1cf2f26bdd7a326a3ef6186ee507fd87868d0.zip Ninja-a2d1cf2f26bdd7a326a3ef6186ee507fd87868d0.tar.gz Ninja-a2d1cf2f26bdd7a326a3ef6186ee507fd87868d0.tar.bz2 |
Fix crash in attempting to canonicalize paths longer than _MAX_PATH
Diffstat (limited to 'src/includes_normalize_test.cc')
-rw-r--r-- | src/includes_normalize_test.cc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/includes_normalize_test.cc b/src/includes_normalize_test.cc index c4c2476..b3519e2 100644 --- a/src/includes_normalize_test.cc +++ b/src/includes_normalize_test.cc @@ -14,6 +14,8 @@ #include "includes_normalize.h" +#include <algorithm> + #include <direct.h> #include "test.h" @@ -102,3 +104,48 @@ TEST(IncludesNormalize, DifferentDrive) { IncludesNormalize::Normalize("P:/vs08\\../wee\\stuff.h", "D:\\stuff/things")); } + +TEST(IncludesNormalize, LongInvalidPath) { + const char kLongInputString[] = + "C:\\Program Files (x86)\\Microsoft Visual Studio " + "12.0\\VC\\INCLUDEwarning #31001: The dll for reading and writing the " + "pdb (for example, mspdb110.dll) could not be found on your path. This " + "is usually a configuration error. Compilation will continue using /Z7 " + "instead of /Zi, but expect a similar error when you link your program."; + // Too long, won't be canonicalized, but just don't crash. + EXPECT_EQ(kLongInputString, + IncludesNormalize::Normalize(kLongInputString, NULL)); + + const char kExactlyMaxPath[] = + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "012345678\\" + "0123456789"; + std::string forward_slashes(kExactlyMaxPath); + std::replace(forward_slashes.begin(), forward_slashes.end(), '\\', '/'); + // Make sure a path that's exactly _MAX_PATH long is canonicalized. + EXPECT_EQ(forward_slashes, + IncludesNormalize::Normalize(kExactlyMaxPath, NULL)); +} |