You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/14 11:28:39 UTC

[GitHub] [incubator-nuttx] fjpanag commented on a diff in pull request #7311: Fix in rename() when old file doesn't exist.

fjpanag commented on code in PR #7311:
URL: https://github.com/apache/incubator-nuttx/pull/7311#discussion_r995657142


##########
fs/vfs/fs_rename.c:
##########
@@ -472,6 +473,14 @@ int rename(FAR const char *oldpath, FAR const char *newpath)
       goto errout;
     }
 
+  /* Ensure that oldpath actually exists */
+
+  ret = nx_stat(oldpath, &stat_buf, 0);

Review Comment:
   @xiaoxiang781216 You are correct about the double search.
   
   But maybe move it after the search and before the `if (INODE_IS_MOUNTPT(oldinode) && *olddesc.relpath != '\0')` conditional? So it also protects `pseudorename()`?
   
   Or `pseudorename()` doesn't need this check? I haven't understood this code 100% yet...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org