From: Aaron Krebs Date: Mon, 3 Nov 2014 14:32:08 +0000 (+0100) Subject: Use strncpy instead of memcpy to not read off the end of source buffer. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=546eb066092803d218c5b31d32af724c42bee2a1;p=meshlink Use strncpy instead of memcpy to not read off the end of source buffer. --- 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);