blobmsg: fill padding between name and data
This commit is contained in:
parent
08aada9a93
commit
7c80b7c514
1 changed files with 5 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue