[PATCH] rpmsg: virtio_rpmsg_bus.c: Cleaning up missing null-terminate in conjunction with strncpy

From: Rickard Strandqvist
Date: Sat Jul 26 2014 - 10:24:47 EST


Replacing strncpy with strlcpy to avoid strings that lacks null terminate.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@xxxxxxxxxxxxxxxxxx>
---
drivers/rpmsg/virtio_rpmsg_bus.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index b6135d4..f5772e1 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -383,7 +383,7 @@ static int rpmsg_dev_probe(struct device *dev)
virtio_has_feature(vrp->vdev, VIRTIO_RPMSG_F_NS)) {
struct rpmsg_ns_msg nsm;

- strncpy(nsm.name, rpdev->id.name, RPMSG_NAME_SIZE);
+ strlcpy(nsm.name, rpdev->id.name, RPMSG_NAME_SIZE);
nsm.addr = rpdev->src;
nsm.flags = RPMSG_NS_CREATE;

@@ -408,7 +408,7 @@ static int rpmsg_dev_remove(struct device *dev)
virtio_has_feature(vrp->vdev, VIRTIO_RPMSG_F_NS)) {
struct rpmsg_ns_msg nsm;

- strncpy(nsm.name, rpdev->id.name, RPMSG_NAME_SIZE);
+ strlcpy(nsm.name, rpdev->id.name, RPMSG_NAME_SIZE);
nsm.addr = rpdev->src;
nsm.flags = RPMSG_NS_DESTROY;

@@ -526,7 +526,7 @@ static struct rpmsg_channel *rpmsg_create_channel(struct virtproc_info *vrp,
*/
rpdev->announce = rpdev->src != RPMSG_ADDR_ANY ? true : false;

- strncpy(rpdev->id.name, chinfo->name, RPMSG_NAME_SIZE);
+ strlcpy(rpdev->id.name, chinfo->name, RPMSG_NAME_SIZE);

/* very simple device indexing plumbing which is enough for now */
dev_set_name(&rpdev->dev, "rpmsg%d", rpmsg_dev_index++);
@@ -925,7 +925,7 @@ static void rpmsg_ns_cb(struct rpmsg_channel *rpdev, void *data, int len,
msg->flags & RPMSG_NS_DESTROY ? "destroy" : "creat",
msg->name, msg->addr);

- strncpy(chinfo.name, msg->name, sizeof(chinfo.name));
+ strlcpy(chinfo.name, msg->name, sizeof(chinfo.name));
chinfo.src = RPMSG_ADDR_ANY;
chinfo.dst = msg->addr;

--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/