Add a check for overflowing the TERMIOS buffer
Should fix #1141 (closed)
Add a check for overflowing the TERIOS buffer