aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2019-08-09 18:19:20 -0700
committerGarrett D'Amore <garrett@damore.org>2019-08-11 10:17:34 -0700
commit57a1d9639d38decd6779b7eb773ab3ead508758d (patch)
tree61ddacaff7918f89985d65b6cf5af4f9e0ff3fce /src/transport
parent8dc9a75d57111d635b413f7628bd0bc61352a3ff (diff)
downloadnng-57a1d9639d38decd6779b7eb773ab3ead508758d.tar.gz
nng-57a1d9639d38decd6779b7eb773ab3ead508758d.tar.bz2
nng-57a1d9639d38decd6779b7eb773ab3ead508758d.zip
fixes #979 ZeroTier fails with zero recvmax
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/zerotier/zerotier.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/transport/zerotier/zerotier.c b/src/transport/zerotier/zerotier.c
index bd8e5d56..552db527 100644
--- a/src/transport/zerotier/zerotier.c
+++ b/src/transport/zerotier/zerotier.c
@@ -1,5 +1,5 @@
//
-// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -841,12 +841,13 @@ zt_pipe_recv_data(zt_pipe *p, const uint8_t *data, size_t len)
// that we only can catch the case where a message is larger by
// more than a fragment, since the final fragment may be shorter,
// and we won't know that until we receive it.
- if ((nfrags * fragsz) >= (p->zp_rcvmax + fragsz)) {
+ if ((p->zp_rcvmax > 0) &&
+ ((nfrags * fragsz) >= (p->zp_rcvmax + fragsz))) {
// Discard, as the forwarder might be on the other side
// of a device. This is gentler than just shutting the pipe
// down. Sending a remote error might be polite, but since
// most peers will close the pipe on such an error, we
- // simply silent discard it.
+ // simply silently discard it.
return;
}
@@ -1717,7 +1718,13 @@ zt_pipe_alloc(
// The largest fragment count we can accept on this pipe.
// This is rounded up to account for alignment.
- maxfrags = (p->zp_rcvmax + (maxfrag - 1)) / maxfrag;
+ if (p->zp_rcvmax > 0) {
+ maxfrags = (p->zp_rcvmax + (maxfrag - 1)) / maxfrag;
+ }
+
+ if ((maxfrags > 0xffff) || (maxfrags == 0)) {
+ maxfrags = 0xffff;
+ }
for (i = 0; i < zt_recvq; i++) {
zt_fraglist *fl = &p->zp_recvq[i];