Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85592 - trunk/boost/thread/win32
From: vicente.botet_at_[hidden]
Date: 2013-09-07 08:11:44


Author: viboes
Date: 2013-09-07 08:11:44 EDT (Sat, 07 Sep 2013)
New Revision: 85592
URL: http://svn.boost.org/trac/boost/changeset/85592

Log:
Thread: protect condition_variable/_any wait_for and wait_until from malicious input.

Text files modified:
   trunk/boost/thread/win32/condition_variable.hpp | 19 +++++++++++++++++--
   1 files changed, 17 insertions(+), 2 deletions(-)

Modified: trunk/boost/thread/win32/condition_variable.hpp
==============================================================================
--- trunk/boost/thread/win32/condition_variable.hpp Sat Sep 7 08:11:18 2013 (r85591)
+++ trunk/boost/thread/win32/condition_variable.hpp 2013-09-07 08:11:44 EDT (Sat, 07 Sep 2013) (r85592)
@@ -366,7 +366,11 @@
                 const chrono::time_point<Clock, Duration>& t)
         {
           using namespace chrono;
- do_wait(lock, ceil<milliseconds>(t-Clock::now()).count());
+ chrono::time_point<Clock, Duration> now = Clock::now();
+ if (t<=now) {
+ return cv_status::timeout;
+ }
+ do_wait(lock, ceil<milliseconds>(t-now).count());
           return Clock::now() < t ? cv_status::no_timeout :
                                              cv_status::timeout;
         }
@@ -378,6 +382,10 @@
                 const chrono::duration<Rep, Period>& d)
         {
           using namespace chrono;
+ if (d<=chrono::duration<Rep, Period>::zero()) {
+ return cv_status::timeout;
+ }
+
           steady_clock::time_point c_now = steady_clock::now();
           do_wait(lock, ceil<milliseconds>(d).count());
           return steady_clock::now() - c_now < d ? cv_status::no_timeout :
@@ -479,7 +487,11 @@
                 const chrono::time_point<Clock, Duration>& t)
         {
           using namespace chrono;
- do_wait(lock, ceil<milliseconds>(t-Clock::now()).count());
+ chrono::time_point<Clock, Duration> now = Clock::now();
+ if (t<=now) {
+ return cv_status::timeout;
+ }
+ do_wait(lock, ceil<milliseconds>(t-now).count());
           return Clock::now() < t ? cv_status::no_timeout :
                                              cv_status::timeout;
         }
@@ -491,6 +503,9 @@
                 const chrono::duration<Rep, Period>& d)
         {
           using namespace chrono;
+ if (d<=chrono::duration<Rep, Period>::zero()) {
+ return cv_status::timeout;
+ }
           steady_clock::time_point c_now = steady_clock::now();
           do_wait(lock, ceil<milliseconds>(d).count());
           return steady_clock::now() - c_now < d ? cv_status::no_timeout :


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk