This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new de136c450b9 fs/hostfs: Fix the host paths in hostfs_rename().
de136c450b9 is described below

commit de136c450b9f16dc0a7c1345de60d4a36513f706
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Oct 19 00:22:08 2026 +0200

    fs/hostfs: Fix the host paths in hostfs_rename().
    
    Commit 86193c95caee changed the two path buffers of hostfs_rename() from
    arrays to pointers, but kept sizeof() as the buffer size.  sizeof() of a
    pointer is 4 or 8, so strlcpy() kept only the first characters of the
    host root directory.  rename() on hostfs then failed with ENOENT, or
    changed a different host path.
    
    hostfs_rename() now makes both paths with hostfs_mkpath() and the size
    HOSTFS_MAX_PATH, as the other hostfs functions do.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 fs/hostfs/hostfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/hostfs/hostfs.c b/fs/hostfs/hostfs.c
index c9157da0ebc..dcecdbf1aa9 100644
--- a/fs/hostfs/hostfs.c
+++ b/fs/hostfs/hostfs.c
@@ -1391,10 +1391,8 @@ int hostfs_rename(FAR struct inode *mountpt, FAR const 
char *oldrelpath,
 
   /* Append to the host's root directory */
 
-  strlcpy(oldpath, fs->fs_root, sizeof(oldpath));
-  strlcat(oldpath, oldrelpath, sizeof(oldpath));
-  strlcpy(newpath, fs->fs_root, sizeof(newpath));
-  strlcat(newpath, newrelpath, sizeof(newpath));
+  hostfs_mkpath(fs, oldrelpath, oldpath, HOSTFS_MAX_PATH);
+  hostfs_mkpath(fs, newrelpath, newpath, HOSTFS_MAX_PATH);
 
   /* Call the host FS to do the mkdir */
 

Reply via email to