From 24fa0c9a6cf1e277232be85192b29fa4fb13031d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 25 Jul 2017 11:03:02 -0700 Subject: [PATCH] In write, buf_w was unchecked. We already checked for room, so the buffer should have room. We make this a kind of assertion; this silences compiler warnings. Later, if this becomes a thread-level race condition, come back and actually use buf_w more meaningfully to handle partial writes. --- src/picoTCP.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/picoTCP.cpp b/src/picoTCP.cpp index 957fc4b..94e98bd 100644 --- a/src/picoTCP.cpp +++ b/src/picoTCP.cpp @@ -746,6 +746,11 @@ namespace ZeroTier { } int buf_w = conn->TXbuf->write((const unsigned char*)data, len); + if (buf_w != len) { + // because we checked ZT_TCP_TX_BUF_SZ above, this should not happen + DEBUG_ERROR("TX wrote only %d but expected to write %d", buf_w, len); + exit(0); + } //DEBUG_INFO("TXbuf->count() = %d", conn->TXbuf->count()); int txsz = conn->TXbuf->count();