[BlueZ 3/9] l2test: Add missing error checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux