mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 10:13:57 +08:00
ktest: Fix while loop in wait_for_input
The run_command function was changed to use the wait_for_input function to
allow having a timeout if the command to run takes too much time. There was
a bug in the wait_for_input where it could end up going into an infinite
loop. There's two issues here. One is that the return value of the sysread
wasn't used for the write (to write a proper size), and that it should
continue processing the passed in file descriptor too even if there was
input. There was no check for error, if for some reason STDIN returned an
error, the function would go into an infinite loop and never exit.
Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Tested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fixes: 6e98d1b441
("ktest: Add timeout to ssh command")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
5739438b72
commit
99c014a879
@ -1904,11 +1904,12 @@ sub wait_for_input
|
||||
|
||||
# copy data from stdin to the console
|
||||
if (vec($rout, fileno(\*STDIN), 1) == 1) {
|
||||
sysread(\*STDIN, $buf, 1000);
|
||||
syswrite($fp, $buf, 1000);
|
||||
next;
|
||||
$nr = sysread(\*STDIN, $buf, 1000);
|
||||
syswrite($fp, $buf, $nr) if ($nr > 0);
|
||||
}
|
||||
|
||||
next if (vec($rout, fileno($fp), 1) != 1);
|
||||
|
||||
$line = "";
|
||||
|
||||
# try to read one char at a time
|
||||
|
Loading…
Reference in New Issue
Block a user