From 845a7bdf820b857569e10577a5ac1c439836bfb0 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 20 Dec 2013 10:29:28 +0200 Subject: [PATCH] tools/l2cap-tester: Fix checking for read() return values --- tools/l2cap-tester.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c index 7d0f3de06..7c50f26a1 100644 --- a/tools/l2cap-tester.c +++ b/tools/l2cap-tester.c @@ -509,7 +509,11 @@ static gboolean client_received_data(GIOChannel *io, GIOCondition cond, int sk; sk = g_io_channel_unix_get_fd(io); - read(sk, buf, l2data->data_len); + if (read(sk, buf, l2data->data_len) != l2data->data_len) { + tester_warn("Unable to read %u bytes", l2data->data_len); + tester_test_failed(); + return FALSE; + } if (memcmp(buf, l2data->read_data, l2data->data_len)) tester_test_failed(); @@ -528,7 +532,12 @@ static gboolean server_received_data(GIOChannel *io, GIOCondition cond, int sk; sk = g_io_channel_unix_get_fd(io); - read(sk, buf, l2data->data_len); + if (read(sk, buf, l2data->data_len) != l2data->data_len) { + tester_warn("Unable to read %u bytes", l2data->data_len); + tester_test_failed(); + close(sk); + return FALSE; + } if (memcmp(buf, l2data->read_data, l2data->data_len)) tester_test_failed(); -- 2.47.3