From cf59d49d2566efac30b57d8bc1f6f62373d86ab5 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 15 Feb 2018 23:47:07 +0100 Subject: [PATCH] Detect failure of device information read If the received data is smaller than the device information size, then something is wrong. --- app/src/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/device.c b/app/src/device.c index 761e2446..a166274f 100644 --- a/app/src/device.c +++ b/app/src/device.c @@ -3,7 +3,8 @@ SDL_bool device_read_info(socket_t device_socket, char *device_name, struct size *size) { unsigned char buf[DEVICE_NAME_FIELD_LENGTH + 4]; - if (net_recv(device_socket, buf, sizeof(buf)) <= 0) { + int r = net_recv(device_socket, buf, sizeof(buf)); + if (r < DEVICE_NAME_FIELD_LENGTH + 4) { LOGE("Could not retrieve device information"); return SDL_FALSE; }