From 7c80b7c5147ac55455464224bd0a3f6aac0b51d0 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 6 Oct 2011 17:19:28 +0200 Subject: [PATCH] blobmsg: fill padding between name and data --- blobmsg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blobmsg.c b/blobmsg.c index 0129640..0551b26 100644 --- a/blobmsg.c +++ b/blobmsg.c @@ -114,6 +114,7 @@ blobmsg_new(struct blob_buf *buf, int type, const char *name, int payload_len, v struct blob_attr *attr; struct blobmsg_hdr *hdr; int attrlen, namelen; + char *pad_start, *pad_end; if (!name) name = ""; @@ -127,7 +128,10 @@ blobmsg_new(struct blob_buf *buf, int type, const char *name, int payload_len, v hdr = blob_data(attr); hdr->namelen = cpu_to_be16(namelen); strcpy((char *) hdr->name, (const char *)name); - *data = blobmsg_data(attr); + pad_end = *data = blobmsg_data(attr); + pad_start = (char *) &hdr->name[namelen]; + if (pad_start < pad_end) + memset(pad_start, 0, pad_end - pad_start); return attr; }