tcgetattr() can fail if stderr is not a terminal (e.g. during redirection). 
Check the return value to prevent operating on uninitialized termios data.

Signed-off-by: Giorgi Tchankvetadze <[email protected]>
---
 console-tools/resize.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/console-tools/resize.c b/console-tools/resize.c
index 6fa7ce9ea..778296b0f 100644
--- a/console-tools/resize.c
+++ b/console-tools/resize.c
@@ -63,8 +63,8 @@ int resize_main(int argc UNUSED_PARAM, char **argv 
UNUSED_PARAM)
         * and operate on it - should we do the same?
         */
 
-       tcgetattr(STDERR_FILENO, old_termios_p); /* fiddle echo */
-//TODO: die if the above fails?
+       if (tcgetattr(STDERR_FILENO, old_termios_p) < 0)
+               bb_simple_perror_msg_and_die("tcgetattr");
        memcpy(&new, old_termios_p, sizeof(new));
        new.c_cflag |= (CLOCAL | CREAD);
        new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
-- 
2.47.3

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to