hartmannathan commented on a change in pull request #5823:
URL: https://github.com/apache/incubator-nuttx/pull/5823#discussion_r832581922
##########
File path: fs/rpmsgfs/rpmsgfs_client.c
##########
@@ -740,8 +741,8 @@ int rpmsgfs_client_rename(FAR void *handle, FAR const char
*oldpath,
DEBUGASSERT(len <= space);
Review comment:
When DEBUGASSERT is a no-op, this check for buffer overflow will not
exist.
I suggest:
```
if (len > space)
{
return -ENOMEM;
}
```
provided `space` is number of bytes we can actually use. If require one more
byte, use `>=` instead:
```
if (len >= space)
{
return -ENOMEM;
}
```
##########
File path: fs/rpmsgfs/rpmsgfs_client.c
##########
@@ -740,8 +741,8 @@ int rpmsgfs_client_rename(FAR void *handle, FAR const char
*oldpath,
DEBUGASSERT(len <= space);
- strcpy(msg->pathname, oldpath);
- strcpy(msg->pathname + oldlen, newpath);
+ memcpy(msg->pathname, oldpath, oldlen);
+ memcpy(msg->pathname + oldlen, newpath, newlen);
Review comment:
Are we supposed to leave one NUL byte between oldpath and newpath in the
buffer? (Asking because I'm not familiar with this protocol.)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]