From b99a6607ba7ad6d571873c3fe19dce864c6e198e Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 8 Aug 2020 22:47:26 -0400 Subject: [PATCH] Use tcflush() in patty_kiss_tnc_new() Use tcflush() to initialize TTY state in patty_kiss_tnc_new(), so that no unexpected data causes KISS framing errors --- src/kiss.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/kiss.c b/src/kiss.c index 30adf45..bdf0e43 100644 --- a/src/kiss.c +++ b/src/kiss.c @@ -143,6 +143,10 @@ patty_kiss_tnc *patty_kiss_tnc_new_fd(int fd) { if (tcsetattr(fd, TCSANOW, &tnc->attrs) < 0) { goto error_tcsetattr; } + + if (tcflush(fd, TCIOFLUSH) < 0) { + goto error_tcflush; + } } tnc->fd = fd; @@ -154,6 +158,7 @@ patty_kiss_tnc *patty_kiss_tnc_new_fd(int fd) { return tnc; +error_tcflush: error_tcsetattr: error_tcgetattr: error_malloc_buf: