mirror of
https://github.com/apache/nuttx.git
synced 2026-08-29 13:20:45 +00:00
Root cause: _inode_search() built the absolute form of a relative path with snprintf(buf, PATH_MAX, "%s/%s", cwd, path), silently truncating it when cwd + "/" + path exceeded PATH_MAX. The truncated buffer was then handed to _inode_canonicalize(), which collapsed ".." segments against the wrong cut-off suffix. A valid relative path of PATH_MAX-1 bytes (legal per pathconf(_PC_PATH_MAX)) could thus collapse onto a directory and open() returned EISDIR instead of resolving the file. Fix: size the temp buffer to hold the full uncanonicalized "<cwd>/<path>" form so canonicalization sees the complete path. lib_get_tempbuffer falls back to a malloc'd buffer when the size exceeds PATH_MAX (CONFIG_LIBC_TEMPBUFFER_MALLOC). The existing PATH_MAX check in _inode_canonicalize() still rejects any canonicalized result that is too long, so ENAMETOOLONG semantics are preserved. Signed-off-by: dengwenqi <dengwenqi@xiaomi.com> |
||
|---|---|---|
| .. | ||
| CMakeLists.txt | ||
| fs_files.c | ||
| fs_foreachinode.c | ||
| fs_inode.c | ||
| fs_inodeaddref.c | ||
| fs_inodebasename.c | ||
| fs_inodefind.c | ||
| fs_inodefree.c | ||
| fs_inodegetpath.c | ||
| fs_inoderelease.c | ||
| fs_inoderemove.c | ||
| fs_inodereserve.c | ||
| fs_inodesearch.c | ||
| inode.h | ||
| Make.defs | ||