From c80f6aa9161e10259127b3b9abe7717c702daf39 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 24 Feb 2017 10:29:05 +0100 Subject: termios: Fix infinite loop in receive path In canonical mode, the raw input buffer or the canonical buffer may overflow without an end of line. Avoid an infinite loop in this case. Close #2915. --- cpukit/libcsupport/src/termios.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'cpukit/libcsupport/src/termios.c') diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c index 62964e4747..f5bf493966 100644 --- a/cpukit/libcsupport/src/termios.c +++ b/cpukit/libcsupport/src/termios.c @@ -1504,13 +1504,17 @@ fillBufferQueue (struct rtems_termios_tty *tty) /* * Wait for characters */ - if ( wait ) { - rtems_status_code sc; + if (wait) { + if (tty->ccount < CBUFSIZE - 1) { + rtems_status_code sc; - sc = rtems_semaphore_obtain( - tty->rawInBuf.Semaphore, tty->rawInBufSemaphoreOptions, timeout); - if (sc != RTEMS_SUCCESSFUL) + sc = rtems_semaphore_obtain( + tty->rawInBuf.Semaphore, tty->rawInBufSemaphoreOptions, timeout); + if (sc != RTEMS_SUCCESSFUL) + break; + } else { break; + } } } } -- cgit v1.2.3