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.
This commit is contained in:
Gleb Chesnokov
2026-10-21 13:20:12 +03:00
parent 99786118c8
commit bf2d1d348b
+1 -1
View File
@@ -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;