mirror of
https://github.com/apache/nuttx.git
synced 2026-10-06 11:03:16 +08:00
fs/procfs: fix buffer overflow in mount_sprintf
vsnprintf() returns the total formatted string length even when truncated to info->line. Passing this untruncated length to procfs_memcpy causes a read beyond the 64-byte line staging buffer. Fixes #20011 Signed-off-by: Hritik Naik <hritiknaik16@gmail.com>
This commit is contained in:
committed by
Alan C. Assis
parent
e6d8fe32ea
commit
2a6a86cb68
@@ -182,6 +182,11 @@ static void mount_sprintf(FAR struct mount_info_s *info,
|
||||
linesize = vsnprintf(info->line, info->linelen, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (linesize >= info->linelen)
|
||||
{
|
||||
linesize = info->linelen - 1;
|
||||
}
|
||||
|
||||
/* Copy the line buffer to the user buffer */
|
||||
|
||||
copysize = procfs_memcpy(info->line, linesize,
|
||||
|
||||
Reference in New Issue
Block a user