diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-04 15:39:47 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-04 16:01:48 +0300 |
commit | fe2c12bfe9fdc2713724bb400172e9915477cd65 (patch) | |
tree | e4445ee6344602d3676e59473cb410905a7a72ce /src/path.cpp | |
parent | get rid of SafeInt (diff) | |
download | winapi-common-fe2c12bfe9fdc2713724bb400172e9915477cd65.tar.gz winapi-common-fe2c12bfe9fdc2713724bb400172e9915477cd65.zip |
fix compiler warnings
Diffstat (limited to 'src/path.cpp')
-rw-r--r-- | src/path.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/path.cpp b/src/path.cpp index 3df5918..7848df2 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -9,6 +9,8 @@ #include <windows.h> +#include <limits> +#include <stdexcept> #include <string> #include <vector> @@ -23,7 +25,10 @@ std::wstring do_canonicalize(const std::wstring& path) { buffer.resize(init_buffer_size); while (true) { - const auto nch = ::GetFullPathNameW(path.c_str(), buffer.size(), buffer.data(), NULL); + if (buffer.size() > std::numeric_limits<DWORD>::max()) + throw std::range_error{"Path buffer is too large"}; + const auto nch = ::GetFullPathNameW( + path.c_str(), static_cast<DWORD>(buffer.size()), buffer.data(), NULL); if (nch == 0) { throw error::windows(GetLastError(), "GetFullPathNameW"); |