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

commit 6318b76fc012d61a148df67166e402c256a958d8
Author: zhaoxingyu1 <[email protected]>
AuthorDate: Wed Nov 12 15:30:33 2025 +0800

    fs/rpmsgfs: copy the mount options into a temporary buffer
    
    rpmsgfs_bind() duplicates the option string only to tokenize it and
    frees the copy before it returns. Take the copy from the temporary
    buffer meant for such short-lived data instead of the file system heap.
    
    Signed-off-by: zhaoxingyu1 <[email protected]>
    Signed-off-by: Bowen Wang <[email protected]>
---
 fs/rpmsgfs/rpmsgfs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/rpmsgfs/rpmsgfs.c b/fs/rpmsgfs/rpmsgfs.c
index b0902b43ca7..7767d32c755 100644
--- a/fs/rpmsgfs/rpmsgfs.c
+++ b/fs/rpmsgfs/rpmsgfs.c
@@ -1057,6 +1057,7 @@ static int rpmsgfs_bind(FAR struct inode *blkdriver, FAR 
const void *data,
   FAR struct rpmsgfs_mountpt_s  *fs;
   FAR const char *cpuname = NULL;
   FAR char *options;
+  size_t data_size;
   char *saveptr;
   char *ptr;
   int len;
@@ -1084,13 +1085,16 @@ static int rpmsgfs_bind(FAR struct inode *blkdriver, 
FAR const void *data,
    *  "timeout=xx", connect timeout, unit (ms)
    */
 
-  options = fs_heap_strdup(data);
+  data_size = strlen(data) + 1;
+  options = lib_get_tempbuffer(data_size);
   if (!options)
     {
       fs_heap_free(fs);
       return -ENOMEM;
     }
 
+  memcpy(options, data, data_size);
+
   /* Set timeout default value */
 
   fs->timeout = INT_MAX;
@@ -1115,7 +1119,7 @@ static int rpmsgfs_bind(FAR struct inode *blkdriver, FAR 
const void *data,
     }
 
   ret = rpmsgfs_client_bind(&fs->handle, cpuname);
-  fs_heap_free(options);
+  lib_put_tempbuffer(options);
   if (ret < 0)
     {
       fs_heap_free(fs);

Reply via email to