Closed dcb314 closed 2 years ago
I doubt that linux usbfs would be malicious actor, but nevertheless excellent catch, thanks!
Thank you. Would it be a good idea to use cppcheck in your development process ?
I use it in mine and I think it is very good.
Static analyser cppcheck says:
mtp/backend/linux/usb/Context.cpp:44:9: error: Width 256 given in format string (no. 2) is larger than destination buffer 'portBuf[256]', use %255[0-9.] to prevent overflowing it. [invalidScanfFormatWidth]
Source code is
if (sscanf(entry.c_str(), "%u-%256[0-9.]:%u.%u", &busId, portBuf, &conf, &interface) == 4)
Suggest new code:
if (sscanf(entry.c_str(), "%u-%255[0-9.]:%u.%u", &busId, portBuf, &conf, &interface) == 4)