send() might fail and return a negative len, catch that to avoid advancing the send buffer in the wrong direction and causing all sorts of problems. 977|-> len = send(sk, buf + sent, buflen, 0); 978| 979| sent += len; --- tools/l2test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/l2test.c b/tools/l2test.c index 011a68c3781e..7b6c36e165da 100644 --- a/tools/l2test.c +++ b/tools/l2test.c @@ -975,6 +975,11 @@ static void do_send(int sk) buflen = (size > omtu) ? omtu : size; len = send(sk, buf + sent, buflen, 0); + if (len < 0) { + syslog(LOG_ERR, "Send failed: %s (%d)", + strerror(errno), errno); + exit(1); + } sent += len; size -= len; -- 2.45.1