From a1b8f9611129d6439451b367f4181087f4149cfa Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Wed, 3 Aug 2016 17:25:36 +0800 Subject: [PATCH] fixed a potential buffer overrun in Path_WIN32U.cpp (noncritical, as the failing code should never be reached) --- Foundation/src/Path_WIN32.cpp | 2 ++ Foundation/src/Path_WIN32U.cpp | 9 ++++++--- Foundation/src/Path_WINCE.cpp | 7 +++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Foundation/src/Path_WIN32.cpp b/Foundation/src/Path_WIN32.cpp index 1c0f0422a..70cb973fc 100644 --- a/Foundation/src/Path_WIN32.cpp +++ b/Foundation/src/Path_WIN32.cpp @@ -129,6 +129,7 @@ std::string PathImpl::tempHomeImpl() return tempImpl(); } + std::string PathImpl::tempImpl() { char buffer[MAX_PATH]; @@ -166,6 +167,7 @@ std::string PathImpl::configImpl() return result; } + std::string PathImpl::nullImpl() { return "NUL:"; diff --git a/Foundation/src/Path_WIN32U.cpp b/Foundation/src/Path_WIN32U.cpp index 1550ddfbb..617ca139b 100644 --- a/Foundation/src/Path_WIN32U.cpp +++ b/Foundation/src/Path_WIN32U.cpp @@ -139,6 +139,7 @@ std::string PathImpl::tempHomeImpl() return tempImpl(); } + std::string PathImpl::tempImpl() { Buffer buffer(MAX_PATH_LEN); @@ -177,6 +178,7 @@ std::string PathImpl::configImpl() return result; } + std::string PathImpl::nullImpl() { return "NUL:"; @@ -203,10 +205,11 @@ std::string PathImpl::expandImpl(const std::string& path) void PathImpl::listRootsImpl(std::vector& roots) { roots.clear(); - wchar_t buffer[128]; - DWORD n = GetLogicalDriveStringsW(sizeof(buffer)/sizeof(wchar_t) - 1, buffer); + const int bufferSize = 128; + wchar_t buffer[bufferSize]; + DWORD n = GetLogicalDriveStringsW(bufferSize - 1, buffer); wchar_t* it = buffer; - wchar_t* end = buffer + (n > sizeof(buffer) ? sizeof(buffer) : n); + wchar_t* end = buffer + (n > bufferSize ? bufferSize : n); while (it < end) { std::wstring udev; diff --git a/Foundation/src/Path_WINCE.cpp b/Foundation/src/Path_WINCE.cpp index 96b7c67fb..f4ae60b17 100644 --- a/Foundation/src/Path_WINCE.cpp +++ b/Foundation/src/Path_WINCE.cpp @@ -31,36 +31,43 @@ std::string PathImpl::currentImpl() return("\\"); } + std::string PathImpl::homeImpl() { return("\\"); } + std::string PathImpl::configHomeImpl() { return homeImpl(); } + std::string PathImpl::dataHomeImpl() { return homeImpl(); } + std::string PathImpl::cacheHomeImpl() { return homeImpl(); } + std::string PathImpl::tempHomeImpl() { return tempImpl(); } + std::string PathImpl::configImpl() { return("\\"); } + std::string PathImpl::systemImpl() { return("\\");