Sets *cursor to NULL and returns NULL when a pull fails. */
| 9 | |
| 10 | /* Sets *cursor to NULL and returns NULL when a pull fails. */ |
| 11 | static const u8 *pull(const u8 **cursor, size_t *max, void *copy, size_t n) |
| 12 | { |
| 13 | const u8 *p = *cursor; |
| 14 | |
| 15 | if (*max < n) { |
| 16 | *cursor = NULL; |
| 17 | *max = 0; |
| 18 | /* Just make sure we don't leak uninitialized mem! */ |
| 19 | if (copy) |
| 20 | memset(copy, 0, n); |
| 21 | return NULL; |
| 22 | } |
| 23 | *cursor += n; |
| 24 | *max -= n; |
| 25 | assert(p); |
| 26 | if (copy) |
| 27 | memcpy(copy, p, n); |
| 28 | return memcheck(p, n); |
| 29 | } |
| 30 | |
| 31 | static u32 pull_le32(const u8 **cursor, size_t *max) |
| 32 | { |
no outgoing calls
no test coverage detected