You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/03/23 08:52:54 UTC
[incubator-nuttx] branch master updated: Fix rpmsgfs/rpmsgfs_client.c:774:3: warning: 'strcpy' writing 1 or more bytes into a region of size 0 overflows the destination
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 4d8c926 Fix rpmsgfs/rpmsgfs_client.c:774:3: warning: 'strcpy' writing 1 or more bytes into a region of size 0 overflows the destination
4d8c926 is described below
commit 4d8c92603b974d9890207380775db086229a67b1
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Mar 22 00:04:10 2022 +0800
Fix rpmsgfs/rpmsgfs_client.c:774:3: warning: 'strcpy' writing 1 or more bytes into a region of size 0 overflows the destination
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
fs/rpmsgfs/rpmsgfs_client.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/fs/rpmsgfs/rpmsgfs_client.c b/fs/rpmsgfs/rpmsgfs_client.c
index 855d532..a2cba3a 100644
--- a/fs/rpmsgfs/rpmsgfs_client.c
+++ b/fs/rpmsgfs/rpmsgfs_client.c
@@ -726,11 +726,12 @@ int rpmsgfs_client_rename(FAR void *handle, FAR const char *oldpath,
struct rpmsgfs_rename_s *msg;
size_t len;
size_t oldlen;
+ size_t newlen;
uint32_t space;
- len = sizeof(*msg);
- oldlen = (strlen(oldpath) + 1 + 0x7) & ~0x7;
- len += oldlen + strlen(newpath) + 1;
+ oldlen = strlen(oldpath) + 1;
+ newlen = strlen(newpath) + 1;
+ len = sizeof(*msg) + oldlen + newlen;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg)
@@ -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);
return rpmsgfs_send_recv(priv, RPMSGFS_RENAME, false,
(struct rpmsgfs_header_s *)msg, len, NULL);