blobmsg: fill padding between name and data

This commit is contained in:
Felix Fietkau 2011-10-06 17:19:28 +02:00
parent 08aada9a93
commit 7c80b7c514

View file

@ -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;
}