diff options
author | 2016-07-11 18:05:23 -0400 | |
---|---|---|
committer | 2016-07-11 18:05:23 -0400 | |
commit | 210d5cb4513b7ba67b6990624cf19fee1ee0a9f9 (patch) | |
tree | 842c9266edcd1acd7204963b1e82e3b9b53ebedf /src/lib/util/corefile.cpp | |
parent | 32230ae6485f76c7d0745c3e981a6aa14d4e0be0 (diff) |
Fixed issue that could cause core_filename_ends_with() to return true when extension.size() > filename.size()
Diffstat (limited to 'src/lib/util/corefile.cpp')
-rw-r--r-- | src/lib/util/corefile.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp index 5c530b41f30..c06426015f7 100644 --- a/src/lib/util/corefile.cpp +++ b/src/lib/util/corefile.cpp @@ -1298,15 +1298,16 @@ bool core_filename_ends_with(const std::string &filename, const std::string &ext { auto namelen = filename.length(); auto extlen = extension.length(); - bool matches = true; + // first if the extension is bigger than the name, we definitely don't match + bool matches = namelen >= extlen; + // work backwards checking for a match - while (extlen > 0 && namelen > 0) + while (matches && extlen > 0 && namelen > 0) + { if (tolower((UINT8)filename[--namelen]) != tolower((UINT8)extension[--extlen])) - { matches = false; - break; - } + } return matches; } |