| 20 | } |
| 21 | |
| 22 | u8 *wire_sync_read(const tal_t *ctx, int fd) |
| 23 | { |
| 24 | wire_len_t len; |
| 25 | u8 *msg; |
| 26 | |
| 27 | if (!read_all(fd, &len, sizeof(len))) |
| 28 | return NULL; |
| 29 | if (wirelen_to_cpu(len) >= WIRE_LEN_LIMIT) { |
| 30 | errno = E2BIG; |
| 31 | return NULL; |
| 32 | } |
| 33 | msg = tal_arr(ctx, u8, wirelen_to_cpu(len)); |
| 34 | if (!read_all(fd, msg, wirelen_to_cpu(len))) |
| 35 | return tal_free(msg); |
| 36 | return msg; |
| 37 | } |
no test coverage detected