Abort with an error if the buffer is too small
Silently truncating the data packet if the buffer is too small will result in a corrupt data stream.
This commit is contained in:
parent
eae071c97d
commit
06259fed19
@ -85,8 +85,8 @@ receive_data (uwatec_g2_device_t *device, unsigned char *data, unsigned int size
|
||||
}
|
||||
HEXDUMP (device->base.context, DC_LOGLEVEL_DEBUG, "rcv", buf + 1, len);
|
||||
if (len > size) {
|
||||
ERROR (device->base.context, "receive result buffer too small - truncating");
|
||||
len = size;
|
||||
ERROR (device->base.context, "receive result buffer too small");
|
||||
return DC_STATUS_PROTOCOL;
|
||||
}
|
||||
memcpy(data, buf + 1, len);
|
||||
size -= len;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user