From 11e346d477da9f52b7ebcbe987994b181fe630fb Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.i.king@gmail.com>
Date: Wed, 3 May 2023 11:20:36 +0100
Subject: [PATCH] parse_config: limit sscanf %s size to avoid buffer overflow
 in buf
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

Limit the sscanf %s scan size to 127 bytes (buf size - 1) to ensure
string and end of string marker '\0' can fit into the 128 byte buf
to avoid buffer overflow.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 src/parse_config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: psst-1.0/src/parse_config.c
===================================================================
--- psst-1.0.orig/src/parse_config.c
+++ psst-1.0/src/parse_config.c
@@ -280,7 +280,7 @@ int parse_cmd_config(int ac, char **av,
 			sscanf(optarg, "%d", &configp->duration);
 			break;
 		case 'C':
-			sscanf(optarg, "%s", buf);
+			sscanf(optarg, "%127s", buf);
 			if (set_cpu_mask(buf, configp) < 0)
 				return 0;
 			break;
