diff --git a/blobmsg.c b/blobmsg.c index 48dba81..37821c3 100644 --- a/blobmsg.c +++ b/blobmsg.c @@ -240,7 +240,10 @@ blobmsg_new(struct blob_buf *buf, int type, const char *name, int payload_len, v attr->id_len |= be32_to_cpu(BLOB_ATTR_EXTENDED); hdr = blob_data(attr); hdr->namelen = cpu_to_be16(namelen); - strcpy((char *) hdr->name, (const char *)name); + + memcpy(hdr->name, name, namelen); + hdr->name[namelen] = '\0'; + pad_end = *data = blobmsg_data(attr); pad_start = (char *) &hdr->name[namelen]; if (pad_start < pad_end)