mirror of
https://github.com/SCST-project/scst.git
synced 2026-10-22 06:02:33 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user