mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
fs/hostfs: Fix long root path construction
hostfs_mkpath() appends a relative path to the configured host root with strlcat(). The third argument to strlcat() is the total destination buffer size, not the remaining free space. Passing pathlen - strlen(path) makes the effective limit shrink after a long host root has already been copied. With a sufficiently long root, a valid relative path can be dropped or truncated, so operations under the mount point may resolve to the host root instead of the requested child path. Pass the full destination buffer size and let strlcat() account for the current string length internally. The companion examples/hostfs_longpath app validates this regression by mounting hostfs with a long host root, writing a probe file below the mount point, and reading it back. The old size argument drops the relative component in that scenario; this fix preserves it. Assisted-by: Claude:Claude-Fable-5 Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
parent
b5d3d30378
commit
778f7f00cb
1 changed files with 1 additions and 1 deletions
|
|
@ -230,7 +230,7 @@ static void hostfs_mkpath(FAR struct hostfs_mountpt_s *fs,
|
|||
|
||||
if (depth >= 0)
|
||||
{
|
||||
strlcat(path, &relpath[first], pathlen - strlen(path));
|
||||
strlcat(path, &relpath[first], pathlen);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue