static inline struct blob_attr *
offset_to_attr(struct blob_buf *buf, int offset)
{
- void *ptr = (char *)buf->buf + offset;
+ void *ptr = (char *)buf->buf + offset - BLOB_COOKIE;
return ptr;
}
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
blob_add(struct blob_buf *buf, struct blob_attr *pos, int id, int payload)
{
int offset = attr_to_offset(buf, pos);
- int required = (offset + sizeof(struct blob_attr) + payload) - buf->buflen;
+ int required = (offset - BLOB_COOKIE + sizeof(struct blob_attr) + payload) - buf->buflen;
struct blob_attr *attr;
if (required > 0) {
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;
}
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)