fixed a potential buffer overrun in Path_WIN32U.cpp (noncritical, as the failing code should never be reached)

This commit is contained in:
Guenter Obiltschnig 2016-08-03 17:25:36 +08:00
parent aed776b7ae
commit a1b8f96111
3 changed files with 15 additions and 3 deletions

View File

@ -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:";

View File

@ -139,6 +139,7 @@ std::string PathImpl::tempHomeImpl()
return tempImpl();
}
std::string PathImpl::tempImpl()
{
Buffer<wchar_t> 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<std::string>& 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;

View File

@ -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("\\");