Detect failure of device information read
If the received data is smaller than the device information size, then something is wrong.
This commit is contained in:
parent
9b056f5091
commit
cf59d49d25
1 changed files with 2 additions and 1 deletions
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
SDL_bool device_read_info(socket_t device_socket, char *device_name, struct size *size) {
|
SDL_bool device_read_info(socket_t device_socket, char *device_name, struct size *size) {
|
||||||
unsigned char buf[DEVICE_NAME_FIELD_LENGTH + 4];
|
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");
|
LOGE("Could not retrieve device information");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue