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

David Binderman dcb314 at hotmail.com
Thu Aug 31 03:53:14 PDT 2023


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


More information about the linux-riscv mailing list