unsigned int offset = 0;
TALLOC_CTX *child_ctx;
- if (data_len < 1) return -1; /* at least one byte of data */
+ if (data_len == 0) {
+ fr_strerror_const("struct decoder was passed zero bytes of data");
+ return -1; /* at least one byte of data */
+ }
FR_PROTO_HEX_DUMP(data, data_len, "fr_struct_from_network");
fr_assert(parent->type == FR_TYPE_STRUCT);
struct_vp = fr_pair_afrom_da(ctx, parent);
- if (!struct_vp) return -1;
+ if (!struct_vp) {
+ oom:
+ fr_strerror_const("out of memory");
+ return -1;
+ }
fr_pair_list_init(&head); /* still used elsewhere */
fr_dcursor_init(&child_cursor, &struct_vp->vp_group);
}
vp = fr_raw_from_network(ctx, parent, data, data_len);
- if (!vp) return -1;
+ if (!vp) goto oom;
/*
* And append this one VP to the output cursor.
if (!vp) {
FR_PROTO_TRACE("Failed creating raw VP from malformed or unknown substruct");
fr_dict_unknown_free(&child);
- return -(p - data);
+ goto oom;
}
fr_dcursor_append(&child_cursor, vp);