diff options
author | Philip Prindeville <philipp@redfish-solutions.com> | 2018-03-28 08:25:28 -0600 |
---|---|---|
committer | Azat Khuzhin <a3at.mail@gmail.com> | 2018-03-30 01:24:25 +0300 |
commit | 33baa4e59fbf9432d77a19c6b2b45402580b79a5 (patch) | |
tree | d8265f3ce21fc4f8e5f371cd0dfa855568a0fb1b /evutil_time.c | |
parent | 4ba48739673060baea581774992970fa46c2f813 (diff) | |
download | libevent-33baa4e59fbf9432d77a19c6b2b45402580b79a5.tar.gz |
Avoid possible SEGVs in select() (in unit tests)
Per the POSIX definition of select():
http://pubs.opengroup.org/onlinepubs/009696699/functions/pselect.html
"Upon successful completion, the select() function may modify the object
pointed to by the timout argument."
If "struct timeval" pointer is a "static const", it could potentially
be allocated in a RO text segment. The kernel would then try to copy
back the modified value (with the time remaining) into a read-only
address and SEGV.
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Closes: #614
Diffstat (limited to 'evutil_time.c')
-rw-r--r-- | evutil_time.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/evutil_time.c b/evutil_time.c index 00fd5fb4..d658b30e 100644 --- a/evutil_time.c +++ b/evutil_time.c @@ -141,7 +141,10 @@ evutil_usleep_(const struct timeval *tv) sleep(tv->tv_sec); usleep(tv->tv_usec); #else - select(0, NULL, NULL, NULL, tv); + { + struct timeval tv2 = *tv; + select(0, NULL, NULL, NULL, &tv2); + } #endif } |