]> git.meshlink.io Git - meshlink/commitdiff
Use strncpy instead of memcpy to not read off the end of source buffer.
authorAaron Krebs <aaron.krebs@everbase.net>
Mon, 3 Nov 2014 14:32:08 +0000 (15:32 +0100)
committerGuus Sliepen <guus@meshlink.io>
Sat, 27 Dec 2014 17:29:08 +0000 (18:29 +0100)
src/meshlink.c

index df695b15fa9855a6c5ab9bbee668b39b56cb0fc6..918a62b6e500c8affcd01c3763e21cab27276247 100644 (file)
@@ -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);