linux-6.5/tools/tracing/rtla/src/utils.c:548:invalidScanfFormatWidth

From: David Binderman
Date: Thu Aug 31 2023 - 06:53:24 EST


Hello there,

I just tried the static analyser cppcheck over the source code of linux-6.5
and got this:

linux-6.5/tools/tracing/rtla/src/utils.c:548:9: error: Width 1024 given in format string (no. 1) is larger than destination buffer 'mount_point[1024]', use %1023s to prevent overflowing it. [invalidScanfFormatWidth]

Source code is

while (fscanf(fp, "%*s %" STR(MAX_PATH) "s %99s %*s %*d %*d\n", mount_point, type) == 2) {

Maybe better code:

while (fscanf(fp, "%*s %" STR(MAX_PATH - 1) "s %99s %*s %*d %*d\n", mount_point, type) == 2) {

Regards

David Binderman