From 78b9defa2bb33424fd5a0609bdd84be2d36ba881 Mon Sep 17 00:00:00 2001 From: Caleb An Date: Wed, 3 Feb 2021 16:33:38 -0800 Subject: [PATCH] ensure setValue stays within buffer size --- server/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/main.c b/server/main.c index 6e36a82..a27a79b 100644 --- a/server/main.c +++ b/server/main.c @@ -262,7 +262,8 @@ static void setValue( char * pSource, char dest[] ) { // Destination is always one of our static buffers with size BUFSIZE memset( dest, 0, BUFSIZE ); - memcpy( dest, pSource, strlen(pSource) ); + int length = (strlen(pSource) < BUFSIZE - 1) ? strlen(pSource) : (BUFSIZE - 1); + memcpy( dest, pSource, length ); } static void setDataDir(char *pData)