Skip to content

Commit

Permalink
tuntap: fix reading too much (useless) data.
Browse files Browse the repository at this point in the history
In cases when we read more data from the tuntap device than we can handle
we just truncate the packet for now.
  • Loading branch information
zehome committed Dec 13, 2016
1 parent 4ae10b5 commit bc34fb8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/tuntap_bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mlvpn_tuntap_read(struct tuntap_s *tuntap)
iov[0].iov_base = &type;
iov[0].iov_len = sizeof(type);
iov[1].iov_base = &data;
iov[1].iov_len = DEFAULT_MTU;
iov[1].iov_len = tuntap->maxmtu;
ret = readv(tuntap->fd, iov, 2);
if (ret < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
Expand Down
2 changes: 1 addition & 1 deletion src/tuntap_darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mlvpn_tuntap_read(struct tuntap_s *tuntap)
{
ssize_t ret;
u_char data[DEFAULT_MTU];
ret = read(tuntap->fd, &data, DEFAULT_MTU);
ret = read(tuntap->fd, &data, tuntap->maxmtu);
if (ret < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
/* read error on tuntap is not recoverable. We must die. */
Expand Down
2 changes: 1 addition & 1 deletion src/tuntap_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mlvpn_tuntap_read(struct tuntap_s *tuntap)
{
ssize_t ret;
u_char data[DEFAULT_MTU];
ret = read(tuntap->fd, &data, DEFAULT_MTU);
ret = read(tuntap->fd, &data, tuntap->maxmtu);
if (ret < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
/* read error on tuntap is not recoverable. We must die. */
Expand Down

0 comments on commit bc34fb8

Please sign in to comment.