um: mconsole: use bounded version string formatting

mconsole_version() formats several UTS strings into a fixed 256-byte
local buffer with sprintf() and no length bound.

Use snprintf() so the version reply stays within the local buffer.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Link: https://patch.msgid.link/20260408160001.1-um-mconsole-v2-pengpeng@iscas.ac.cn
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Pengpeng Hou 2026-04-08 15:35:13 +08:00 committed by Johannes Berg
parent 2f89719949
commit 5bde583d13

View File

@ -106,9 +106,9 @@ void mconsole_version(struct mc_request *req)
{
char version[256];
sprintf(version, "%s %s %s %s %s", utsname()->sysname,
utsname()->nodename, utsname()->release, utsname()->version,
utsname()->machine);
snprintf(version, sizeof(version), "%s %s %s %s %s",
utsname()->sysname, utsname()->nodename, utsname()->release,
utsname()->version, utsname()->machine);
mconsole_reply(req, version, 0, 0);
}