From 773e88d3742739e1a6375b166967d8595965b0e7 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 17 Mar 2021 21:19:45 +0100 Subject: [PATCH] Fix potential channel buffer corruption when using an application-provided buffer. If data was still in MeshLink's internal buffer in a wrapped state, and the application called meshlink_set_channel_*buf_storage(), the wrong amount of data was copied into the new buffer. --- src/utcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utcp.c b/src/utcp.c index 9e2229ad..2fe65050 100644 --- a/src/utcp.c +++ b/src/utcp.c @@ -2326,7 +2326,7 @@ static void buffer_transfer(struct buffer *buf, char *newdata, size_t newsize) { // [012345......] uint32_t tailsize = buf->size - buf->offset; memcpy(newdata, buf->data + buf->offset, tailsize); - memcpy(newdata + tailsize, buf->data, buf->used - buf->offset); + memcpy(newdata + tailsize, buf->data, buf->used - tailsize); } else { // Old situation: // [....012345..] -- 2.39.5