From 06259fed1937ac3663922c5e1eebfa118933293c Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 20 Jun 2017 21:25:36 +0200 Subject: [PATCH] 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. --- src/uwatec_g2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uwatec_g2.c b/src/uwatec_g2.c index 2fa86c8..388b82c 100644 --- a/src/uwatec_g2.c +++ b/src/uwatec_g2.c @@ -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;