| 195 | } |
| 196 | |
| 197 | static struct tlv_field *fromwire_len_and_tlvstream(const tal_t *ctx, |
| 198 | const u8 **cursor, size_t *max) |
| 199 | { |
| 200 | struct tlv_field *tlvs = tal_arr(ctx, struct tlv_field, 0); |
| 201 | size_t len = fromwire_u16(cursor, max); |
| 202 | |
| 203 | /* Subtle: we are not using fromwire_tal_arrn here, which |
| 204 | * would do this. */ |
| 205 | if (len > *max) { |
| 206 | fromwire_fail(cursor, max); |
| 207 | return NULL; |
| 208 | } |
| 209 | |
| 210 | /* NOTE: We might consider to be more strict and only allow for |
| 211 | * known tlv types from the tlvs_tlv_update_add_htlc_tlvs |
| 212 | * record. */ |
| 213 | if (!fromwire_tlv(cursor, &len, NULL, 0, cast_const(void *, ctx), |
| 214 | &tlvs, FROMWIRE_TLV_ANY_TYPE, NULL, NULL)) |
| 215 | return tal_free(tlvs); |
| 216 | return tlvs; |
| 217 | } |
| 218 | |
| 219 | struct added_htlc *fromwire_added_htlc(const tal_t *ctx, const u8 **cursor, |
| 220 | size_t *max) |
no test coverage detected