25 int delta = ((minlen / 256) + 1) * 256;
26 new = realloc(
buf->buf,
buf->buflen + delta);
29 memset(
buf->buf +
buf->buflen, 0, delta);
63 if (!buf->
grow || !buf->
grow(buf, required))
115 char *buf = (
char *) attr;
120 memset(buf + len - delta, 0, delta);
149 if (len <
sizeof(
struct blob_attr) || !ptr)
156 memcpy(attr, ptr, len);
181 return (
void *) offset;
204 const char *
data = ptr;
231 if (!attr || attr_len <
sizeof(
struct blob_attr))
239 if (len > attr_len || len <
sizeof(
struct blob_attr))
254 if (info[
id].minlen && len < info[
id].minlen)
257 if (info[
id].maxlen && len > info[
id].maxlen)
260 if (info[
id].validate && !info[
id].validate(&info[
id], attr))
279 if (!attr || attr_len <
sizeof(
struct blob_attr))
335 memcpy(ret, attr, size);
void blob_set_raw_len(struct blob_attr *attr, unsigned int len)
static int blob_parse_attr(struct blob_attr *attr, size_t attr_len, struct blob_attr **data, const struct blob_attr_info *info, int max)
struct blob_attr * blob_put(struct blob_buf *buf, int id, const void *ptr, unsigned int len)
static const size_t blob_type_minlen[BLOB_ATTR_LAST]
bool blob_attr_equal(const struct blob_attr *a1, const struct blob_attr *a2)
static void blob_init(struct blob_attr *attr, int id, unsigned int len)
void blob_buf_free(struct blob_buf *buf)
struct blob_attr * blob_new(struct blob_buf *buf, int id, int payload)
bool blob_check_type(const void *ptr, unsigned int len, int type)
static bool blob_buffer_grow(struct blob_buf *buf, int minlen)
static struct blob_attr * blob_add(struct blob_buf *buf, struct blob_attr *pos, int id, int payload)
void * blob_nest_start(struct blob_buf *buf, int id)
int blob_parse(struct blob_attr *attr, struct blob_attr **data, const struct blob_attr_info *info, int max)
static int attr_to_offset(struct blob_buf *buf, struct blob_attr *attr)
int blob_parse_untrusted(struct blob_attr *attr, size_t attr_len, struct blob_attr **data, const struct blob_attr_info *info, int max)
void blob_nest_end(struct blob_buf *buf, void *cookie)
bool blob_buf_grow(struct blob_buf *buf, int required)
void blob_fill_pad(struct blob_attr *attr)
struct blob_attr * blob_memdup(struct blob_attr *attr)
static struct blob_attr * offset_to_attr(struct blob_buf *buf, int offset)
struct blob_attr * blob_put_raw(struct blob_buf *buf, const void *ptr, unsigned int len)
int blob_buf_init(struct blob_buf *buf, int id)
static size_t blob_raw_len(const struct blob_attr *attr)
static size_t blob_pad_len(const struct blob_attr *attr)
#define BLOB_ATTR_ID_MASK
static struct blob_attr * blob_next(const struct blob_attr *attr)
#define blob_for_each_attr_len(pos, attr, attr_len, rem)
#define BLOB_ATTR_ID_SHIFT
#define blob_for_each_attr(pos, attr, rem)
static size_t blob_len(const struct blob_attr *attr)
static void * blob_data(const struct blob_attr *attr)
static unsigned int blob_id(const struct blob_attr *attr)
#define BLOB_ATTR_LEN_MASK
bool(* grow)(struct blob_buf *buf, int minlen)