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 <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-03-22 00:04:10 +08:00 committed by Petro Karashchenko
parent 0fcb4575bb
commit 4d8c92603b
1 changed files with 6 additions and 5 deletions

View File

@ -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);