summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-02-24 10:29:05 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-02-28 09:55:58 +0100
commita27128c5dce5d2fcd482a7914750539f8745ff88 (patch)
treee632d4c5547d1803d557a4948146699761a3a2da /cpukit
parent0e8d20555966942f79e0e8ec29ff2104fda1b646 (diff)
downloadrtems-a27128c5dce5d2fcd482a7914750539f8745ff88.tar.bz2
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. Update #2915.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libcsupport/src/termios.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c
index 1a7562e93c..a9603e1c24 100644
--- a/cpukit/libcsupport/src/termios.c
+++ b/cpukit/libcsupport/src/termios.c
@@ -1521,13 +1521,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;
+ }
}
}
}