diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-01-08 00:58:48 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-01-09 00:15:11 +0100 |
commit | 2655fffed7a9e765bcb4701dd876e9dab975f289 (patch) | |
tree | 764002a25445957f4420e6d0e9189f5319a44996 /src/tcp_subr.c | |
parent | 789955c6e1cf5a9ed722138fea5fc8ffd4cbfbd1 (diff) | |
download | slirp-2655fffed7a9e765bcb4701dd876e9dab975f289.zip slirp-2655fffed7a9e765bcb4701dd876e9dab975f289.tar.gz slirp-2655fffed7a9e765bcb4701dd876e9dab975f289.tar.bz2 |
tcp_emu: Fix oob access
The main loop only checks for one available byte, while we sometimes
need two bytes.
Diffstat (limited to 'src/tcp_subr.c')
-rw-r--r-- | src/tcp_subr.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tcp_subr.c b/src/tcp_subr.c index 382aa38..9c1bdec 100644 --- a/src/tcp_subr.c +++ b/src/tcp_subr.c @@ -871,6 +871,9 @@ int tcp_emu(struct socket *so, struct mbuf *m) break; case 5: + if (bptr == m->m_data + m->m_len - 1) + return 1; /* We need two bytes */ + /* * The difference between versions 1.0 and * 2.0 is here. For future versions of @@ -886,6 +889,10 @@ int tcp_emu(struct socket *so, struct mbuf *m) /* This is the field containing the port * number that RA-player is listening to. */ + + if (bptr == m->m_data + m->m_len - 1) + return 1; /* We need two bytes */ + lport = (((uint8_t *)bptr)[0] << 8) + ((uint8_t *)bptr)[1]; if (lport < 6970) lport += 256; /* don't know why */ |