From bf2d1d348b1b06b49335f3a0223321c476442c32 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Wed, 21 Oct 2026 09:51:32 +0300 Subject: [PATCH] iscsi-scstd: Bound the parsed device name explicitly The saved Cppcheck report flags driver_major: iscsi-scst/usr/misc.c:44: warning: sscanf() without field width limits can crash with huge input data. [invalidscanf] The preceding fgets currently bounds input to a 256-byte buffer, so this report does not demonstrate an overflow in the present path. Still, state the 255-character limit in the %s conversion to bind it directly to devname's capacity, including the terminating NUL. --- iscsi-scst/usr/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iscsi-scst/usr/misc.c b/iscsi-scst/usr/misc.c index ba4cf6e84..24643ab2a 100644 --- a/iscsi-scst/usr/misc.c +++ b/iscsi-scst/usr/misc.c @@ -41,7 +41,7 @@ static int driver_major(const char *dev) devn = -ENOENT; while (fgets(buf, sizeof(buf), f)) { - if (sscanf(buf, "%d %s", &devn, devname) == 2 && + if (sscanf(buf, "%d %255s", &devn, devname) == 2 && devn > 0 && strcmp(devname, dev) == 0) break; devn = -ENOENT;