Skip to content

Commit 901fd2a

Browse files
committed
Fix buffer underflow when serial peer spews garbage
A board I got spews garbage on hard reset. Sometimes that garbage is IAC and it leads to len here getting negative and the loop eventually underflows the buf. Detect and avoid this silently.
1 parent a94d4b8 commit 901fd2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static int handle_receive_buf(struct ios_ops *ios, unsigned char *buf, int len)
306306
unsigned char *sendbuf = buf;
307307
int i;
308308

309-
while (len) {
309+
while (len > 0) {
310310
switch (*buf) {
311311
case IAC:
312312
/* BUG: this is telnet specific */

0 commit comments

Comments
 (0)