mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-20 13:24:09 -07:00
Add bigness to buffers to prevent overflow on high traffic (Mac tap).
This commit is contained in:
parent
92c811deb7
commit
d77846dcea
2 changed files with 15 additions and 5 deletions
|
@ -350,10 +350,14 @@ void MacEthernetTap::setMtu(unsigned int mtu)
|
|||
_mtu = mtu;
|
||||
}
|
||||
|
||||
#define ZT_MACETHERNETTAP_AGENT_READ_BUF_SIZE 1048576
|
||||
|
||||
void MacEthernetTap::threadMain()
|
||||
throw()
|
||||
{
|
||||
char agentReadBuf[262144];
|
||||
char *const agentReadBuf = (char *)valloc(ZT_MACETHERNETTAP_AGENT_READ_BUF_SIZE);
|
||||
if (!agentReadBuf)
|
||||
return;
|
||||
fd_set readfds,nullfds;
|
||||
MAC to,from;
|
||||
|
||||
|
@ -375,7 +379,7 @@ void MacEthernetTap::threadMain()
|
|||
break;
|
||||
}
|
||||
if (FD_ISSET(_agentStdout,&readfds)) {
|
||||
long n = (long)read(_agentStdout,agentReadBuf + agentReadPtr,sizeof(agentReadBuf) - agentReadPtr);
|
||||
long n = (long)read(_agentStdout,agentReadBuf + agentReadPtr,ZT_MACETHERNETTAP_AGENT_READ_BUF_SIZE - agentReadPtr);
|
||||
if (n > 0) {
|
||||
agentReadPtr += n;
|
||||
while (agentReadPtr >= 2) {
|
||||
|
@ -401,9 +405,11 @@ void MacEthernetTap::threadMain()
|
|||
}
|
||||
}
|
||||
if (FD_ISSET(_agentStderr,&readfds)) {
|
||||
read(_agentStderr,agentReadBuf,sizeof(agentReadBuf));
|
||||
read(_agentStderr,agentReadBuf,ZT_MACETHERNETTAP_AGENT_READ_BUF_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
free(agentReadBuf);
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue