md5: remove unnecessary variable change
[project/libubox.git] / blobmsg.c
index 62f83cc..b3e485d 100644 (file)
--- a/blobmsg.c
+++ b/blobmsg.c
@@ -181,6 +181,7 @@ blobmsg_new(struct blob_buf *buf, int type, const char *name, int payload_len, v
        if (!attr)
                return NULL;
 
+       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);
@@ -195,14 +196,14 @@ blobmsg_new(struct blob_buf *buf, int type, const char *name, int payload_len, v
 static inline int
 attr_to_offset(struct blob_buf *buf, struct blob_attr *attr)
 {
-       return (char *)attr - (char *) buf->buf;
+       return (char *)attr - (char *) buf->buf + BLOB_COOKIE;
 }
 
 
 void *
 blobmsg_open_nested(struct blob_buf *buf, const char *name, bool array)
 {
-       struct blob_attr *head = buf->head;
+       struct blob_attr *head;
        int type = array ? BLOBMSG_TYPE_ARRAY : BLOBMSG_TYPE_TABLE;
        unsigned long offset = attr_to_offset(buf, buf->head);
        void *data;
@@ -262,7 +263,7 @@ void *
 blobmsg_realloc_string_buffer(struct blob_buf *buf, int maxlen)
 {
        struct blob_attr *attr = blob_next(buf->head);
-       int offset = attr_to_offset(buf, blob_next(buf->head)) + blob_pad_len(attr);
+       int offset = attr_to_offset(buf, blob_next(buf->head)) + blob_pad_len(attr) - BLOB_COOKIE;
        int required = maxlen - (buf->buflen - offset);
 
        if (required <= 0)