Skip to content
Commit fa7a1b3d authored by Tobias Deiminger's avatar Tobias Deiminger
Browse files

Avoid undefined behavior due to dangling file descriptor

Summary:
We request a inhibit lock of DBus type UNIX_FD from systemd logind. It's wrapped into (and owned by) a QDBusUnixFileDescriptor object of automatic storage. The file descriptor will be closed in QDBusUnixFileDescriptor Dtor, and may be reused by some other facility (e.g. pulseaudio).

If we want to store the lock longer than QDBusUnixFileDescriptor lifetime, we have to dup the file descriptor. If we don't dup, and close the original fd later in PresentationWidget::allowPowerManagement, bad things may happen.

Besides that, what we get from systemd is really a file descriptor, not a "cookie". So I renamed the m_sleepInhibitCookie to m_sleepInhibitFd and changed initial state to -1 accordingly.

BUG 393478
BUG 398720

Test Plan:
- bugs don't occur any longer
- inhibiting sleep during presentation mode still works

Reviewers: aacid

Reviewed By: aacid

Subscribers: ngraham, anthonyfieroni, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D15574
parent 8ff7abc1
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment