[hackers] [st] Fix crash due to invalid timespec given to pselect || Ivan Delalande

From: <git_AT_suckless.org>
Date: Tue, 23 Dec 2014 16:21:18 +0100 (CET)

commit 708b697ed77e1ba4e96399ed6cb0f73a37565321
Author: Ivan Delalande <colona_AT_ycc.fr>
Date: Fri Dec 12 08:39:07 2014 +0100

    Fix crash due to invalid timespec given to pselect
    
    If blinktimeout is set to a value greater than 1000, pselect will
    receive a timeout argument with tv_nsec greater than 1E9 (1 sec), and
    fail, making st crash. This patch just ensures that the timespec
    structure is correctly filled with a value properly decomposed between
    tv_sec and tv_nsec.
    
    Reported by JasonWoof on IRC. Thanks!

diff --git a/st.c b/st.c
index fc91334..db9a332 100644
--- a/st.c
+++ b/st.c
_AT_@ -3922,6 +3922,9 @@ run(void) {
                                                         TIMEDIFF(now,
                                                                 lastblink)));
                                         }
+ drawtimeout.tv_sec = \
+ drawtimeout.tv_nsec / 1E9;
+ drawtimeout.tv_nsec %= (long)1E9;
                                 } else {
                                         tv = NULL;
                                 }
Received on Tue Dec 23 2014 - 16:21:18 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 23 2014 - 16:24:14 CET