mirror of
https://github.com/hyprwm/Hyprland
synced 2025-12-20 04:50:03 +01:00
Prevented longjmp into an uninitialised buffer during plugin faults by tracking when the hook jump buffer is actually primed; a missing/invalid buffer now skips the jump and falls back to crash reporting
This commit is contained in:
parent
76ac655c9e
commit
e8a9615204
2 changed files with 6 additions and 0 deletions
|
|
@ -50,6 +50,7 @@ void CHookSystemManager::emit(std::vector<SCallbackFNPtr>* const callbacks, SCal
|
|||
continue;
|
||||
|
||||
try {
|
||||
m_hookFaultJumpBufReady = true;
|
||||
if (!setjmp(m_hookFaultJumpBuf)) {
|
||||
if (SP<HOOK_CALLBACK_FN> fn = cb.fn.lock())
|
||||
(*fn)(fn.get(), info, data);
|
||||
|
|
@ -63,7 +64,11 @@ void CHookSystemManager::emit(std::vector<SCallbackFNPtr>* const callbacks, SCal
|
|||
// TODO: this works only once...?
|
||||
faultyHandles.push_back(cb.handle);
|
||||
Debug::log(ERR, "[hookSystem] Hook from plugin {:x} caused a SIGSEGV, queueing for unloading.", rc<uintptr_t>(cb.handle));
|
||||
} catch (...) {
|
||||
faultyHandles.push_back(cb.handle);
|
||||
Debug::log(ERR, "[hookSystem] Hook from plugin {:x} caused an unknown fault, queueing for unloading.", rc<uintptr_t>(cb.handle));
|
||||
}
|
||||
m_hookFaultJumpBufReady = false;
|
||||
}
|
||||
|
||||
if (needsDeadCleanup)
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class CHookSystemManager {
|
|||
std::vector<SCallbackFNPtr>* getVecForEvent(const std::string& event);
|
||||
|
||||
bool m_currentEventPlugin = false;
|
||||
bool m_hookFaultJumpBufReady = false;
|
||||
jmp_buf m_hookFaultJumpBuf;
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue