Group :: Terminais
RPM: ttyrec
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: 12_ttyplay_fix_select.diff
Download
Download
Description: Check return value of select
Authors: NIIBE Yutaka <gniibe@fsij.org>
Reviewed-By: NIIBE Yutaka <gniibe@fsij.org>
Last-Update: 2010-04-27
--- ttyrec-1.0.8.orig/ttyplay.c 2010-04-27 13:53:01.000000000 +0900
+++ ttyrec-1.0.8/ttyplay.c 2010-04-27 14:18:37.000000000 +0900
@@ -88,7 +88,7 @@
gettimeofday(&start, NULL);
- if (speed == 0)
+ if (speed == 0.0)
diffp = NULL;
else
diff = timeval_diff(drift, timeval_div(diff, speed));
@@ -97,6 +97,7 @@
diff.tv_sec = diff.tv_usec = 0;
}
+ FD_ZERO(&readfs);
FD_SET(STDIN_FILENO, &readfs);
/*
* We use select() for sleeping with subsecond precision.
@@ -105,9 +105,10 @@
* Save "diff" since select(2) may overwrite it to {0, 0}.
*/
struct timeval orig_diff = diff;
- select(1, &readfs, NULL, NULL, diffp); /* skip if a user hits any key */
+ int r;
+ r = select(1, &readfs, NULL, NULL, diffp); /* skip if a user hits any key */
diff = orig_diff; /* Restore the original diff value. */
- if (FD_ISSET(0, &readfs)) { /* a user hits a character? */
+ if (r > 0 && FD_ISSET(0, &readfs)) { /* a user hits a character? */
char c;
read(STDIN_FILENO, &c, 1); /* drain the character */
switch (c) {