[*] Win32 opener: ensure file/dir exists (subject to time of check attack, but its fine to prevent stupid 'open' shellexec exploits. wont save you if io write is available)
This commit is contained in:
parent
1a4a4ad863
commit
9ab0c25b05
@ -75,19 +75,48 @@ namespace Aurora::Processes
|
||||
void DeinitWin32Opener()
|
||||
{
|
||||
gOpenerThread->SendExitSignal();
|
||||
gCondVariable->Broadcast();
|
||||
gCondVariable->Signal();
|
||||
gOpenerThread.reset();
|
||||
}
|
||||
|
||||
AUKN_SYM void OpenUri(const AuString &uri)
|
||||
{
|
||||
if (AuFS::FileExists(uri))
|
||||
{
|
||||
SysPushErrorGeneric("Exploit attempt? Attempted to open existing file/directory via URI ({})", uri);
|
||||
return;
|
||||
}
|
||||
|
||||
AU_LOCK_GUARD(gCondMutex);
|
||||
AuTryInsert(gOpenItems, uri);
|
||||
gCondVariable->Broadcast();
|
||||
gCondVariable->Signal();
|
||||
}
|
||||
|
||||
AUKN_SYM void OpenFile(const AuString &file)
|
||||
{
|
||||
OpenUri(AuIOFS::NormalizePathRet(file));
|
||||
auto path = AuIOFS::NormalizePathRet(file);
|
||||
bool bFileExists {};
|
||||
|
||||
if (!(bFileExists = AuFS::FileExists(path)) &&
|
||||
!AuFS::DirExists(path))
|
||||
{
|
||||
SysPushErrorGeneric("Exploit attempt? Attempted to open non-existent file/directory. (request: {})", file);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bFileExists)
|
||||
{
|
||||
if (!AuFS::IsFileBlocked(path))
|
||||
{
|
||||
SysPushErrorGeneric("Exploit attempt? Attempted to open untrusted file/directory. (request: {})", file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
AU_LOCK_GUARD(gCondMutex);
|
||||
AuTryInsert(gOpenItems, AuMove(path));
|
||||
gCondVariable->Signal();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user