This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch releases/12.8
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/releases/12.8 by this push:
new 7562aff615 fs/tmpfs: Skip any slash at the beginning of relpath
7562aff615 is described below
commit 7562aff6152a71aafaa093d181ff0b021ef4440f
Author: wangjianyu3 <[email protected]>
AuthorDate: Fri Dec 6 23:08:58 2024 +0800
fs/tmpfs: Skip any slash at the beginning of relpath
`tmpfs_stat()` fails when relpath start with slash.
Log
Host
$ adb -s 1234 pull /tmp/subdir
adb: warning: skipping special file '/tmp/subdir/uname' (mode = 0o0)
/tmp/subdir/: 0 files pulled. 1 file skipped.
Device
state_process_list (411): stat failed </tmp/subdir//uname> -1 22
Ref:
https://github.com/apache/nuttx/blame/master/libs/libc/stdlib/lib_realpath.c#L111
Signed-off-by: wangjianyu3 <[email protected]>
---
fs/tmpfs/fs_tmpfs.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/tmpfs/fs_tmpfs.c b/fs/tmpfs/fs_tmpfs.c
index 58c39175e0..e4f5f25b32 100644
--- a/fs/tmpfs/fs_tmpfs.c
+++ b/fs/tmpfs/fs_tmpfs.c
@@ -889,6 +889,14 @@ static int tmpfs_find_object(FAR struct tmpfs_s *fs,
* relpath.
*/
+ /* Skip any slash. */
+
+ while (*segment == '/')
+ {
+ segment++;
+ len--;
+ }
+
next_segment = memchr(segment, '/', len);
if (next_segment)
{