From 546eb066092803d218c5b31d32af724c42bee2a1 Mon Sep 17 00:00:00 2001 From: Aaron Krebs Date: Mon, 3 Nov 2014 15:32:08 +0100 Subject: [PATCH] Use strncpy instead of memcpy to not read off the end of source buffer. --- src/meshlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/meshlink.c b/src/meshlink.c index df695b15..918a62b6 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1050,8 +1050,8 @@ bool meshlink_send(meshlink_handle_t *mesh, meshlink_node_t *destination, const hdr = (meshlink_packethdr_t *)packet->data; memset(hdr, 0, sizeof *hdr); - memcpy(hdr->destination, destination->name, sizeof hdr->destination); - memcpy(hdr->source, mesh->self->name, sizeof hdr->source); + strncpy(hdr->destination, destination->name, sizeof hdr->destination); + strncpy(hdr->source, mesh->self->name, sizeof hdr->source); memcpy(packet->data + sizeof *hdr, data, len); -- 2.39.5