summaryrefslogtreecommitdiff
path: root/xserver/os/WaitFor.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2015-02-11 20:58:48 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2015-02-11 20:58:48 +0000
commit61c5fcfe608b38a9ce64b1db6393c392108cc89d (patch)
tree8ef036e5b54b6717be9c50782761a67170b6042d /xserver/os/WaitFor.c
parent4506119f5eb47a09843e68ff91de6ce5c63d0ba0 (diff)
Update to xserver 1.16.4.
Contains fix for CVE-2015-0255. ok dcoppa@
Diffstat (limited to 'xserver/os/WaitFor.c')
-rw-r--r--xserver/os/WaitFor.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/xserver/os/WaitFor.c b/xserver/os/WaitFor.c
index 3eb15b9b8..343de0c50 100644
--- a/xserver/os/WaitFor.c
+++ b/xserver/os/WaitFor.c
@@ -121,9 +121,9 @@ struct _OsTimerRec {
void *arg;
};
-static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev);
+static void DoTimer(OsTimerPtr timer, CARD32 now, volatile OsTimerPtr *prev);
static void CheckAllTimers(void);
-static OsTimerPtr timers = NULL;
+static volatile OsTimerPtr timers = NULL;
/*****************
* WaitForSomething:
@@ -263,11 +263,14 @@ WaitForSomething(int *pClientsReady)
if ((int) (timers->expires - now) <= 0)
expired = 1;
- while (timers && (int) (timers->expires - now) <= 0)
- DoTimer(timers, now, &timers);
+ if (expired) {
+ OsBlockSignals();
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+ OsReleaseSignals();
- if (expired)
return 0;
+ }
}
}
else {
@@ -281,11 +284,14 @@ WaitForSomething(int *pClientsReady)
if ((int) (timers->expires - now) <= 0)
expired = 1;
- while (timers && (int) (timers->expires - now) <= 0)
- DoTimer(timers, now, &timers);
+ if (expired) {
+ OsBlockSignals();
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+ OsReleaseSignals();
- if (expired)
return 0;
+ }
}
}
if (someReady)
@@ -401,24 +407,25 @@ CheckAllTimers(void)
}
static void
-DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev)
+DoTimer(OsTimerPtr timer, CARD32 now, volatile OsTimerPtr *prev)
{
CARD32 newTime;
OsBlockSignals();
*prev = timer->next;
timer->next = NULL;
+ OsReleaseSignals();
+
newTime = (*timer->callback) (timer, now, timer->arg);
if (newTime)
TimerSet(timer, 0, newTime, timer->callback, timer->arg);
- OsReleaseSignals();
}
OsTimerPtr
TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
OsTimerCallback func, void *arg)
{
- register OsTimerPtr *prev;
+ volatile OsTimerPtr *prev;
CARD32 now = GetTimeInMillis();
if (!timer) {
@@ -470,7 +477,7 @@ Bool
TimerForce(OsTimerPtr timer)
{
int rc = FALSE;
- OsTimerPtr *prev;
+ volatile OsTimerPtr *prev;
OsBlockSignals();
for (prev = &timers; *prev; prev = &(*prev)->next) {
@@ -487,7 +494,7 @@ TimerForce(OsTimerPtr timer)
void
TimerCancel(OsTimerPtr timer)
{
- OsTimerPtr *prev;
+ volatile OsTimerPtr *prev;
if (!timer)
return;
@@ -515,8 +522,12 @@ TimerCheck(void)
{
CARD32 now = GetTimeInMillis();
- while (timers && (int) (timers->expires - now) <= 0)
- DoTimer(timers, now, &timers);
+ if (timers && (int) (timers->expires - now) <= 0) {
+ OsBlockSignals();
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+ OsReleaseSignals();
+ }
}
void