diff options
| author | 2026-02-12 02:43:50 +0100 | |
|---|---|---|
| committer | 2026-02-12 02:43:50 +0100 | |
| commit | 9969b8ebeb2dd2ac66e4d18fc15d0340de6e8d0e (patch) | |
| tree | cad46eb503d50655946b77e38433ce76b9f9563d /src/bplist.c | |
| parent | c4763002d20e845b566edbe499ada85b03d38dc2 (diff) | |
| download | libplist-9969b8ebeb2dd2ac66e4d18fc15d0340de6e8d0e.tar.gz libplist-9969b8ebeb2dd2ac66e4d18fc15d0340de6e8d0e.tar.bz2 | |
bplist: Add overflow check to node offset pointer arithmetic
Credit to OSSFuzz
Diffstat (limited to 'src/bplist.c')
| -rw-r--r-- | src/bplist.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/bplist.c b/src/bplist.c index 308b787..1187c7a 100644 --- a/src/bplist.c +++ b/src/bplist.c | |||
| @@ -852,7 +852,13 @@ static plist_t parse_bin_node_at_index(struct bplist_data *bplist, uint32_t node | |||
| 852 | return NULL; | 852 | return NULL; |
| 853 | } | 853 | } |
| 854 | 854 | ||
| 855 | ptr = bplist->data + UINT_TO_HOST(idx_ptr, bplist->offset_size); | 855 | uint64_t node_offset = UINT_TO_HOST(idx_ptr, bplist->offset_size); |
| 856 | if (node_offset > (uint64_t)bplist->size) { | ||
| 857 | PLIST_BIN_ERR("node offset overflow (%llu)\n", node_offset); | ||
| 858 | bplist->err = PLIST_ERR_PARSE; | ||
| 859 | return NULL; | ||
| 860 | } | ||
| 861 | ptr = bplist->data + node_offset; | ||
| 856 | /* make sure the node offset is in a sane range */ | 862 | /* make sure the node offset is in a sane range */ |
| 857 | if ((ptr < bplist->data+BPLIST_MAGIC_SIZE+BPLIST_VERSION_SIZE) || (ptr >= bplist->offset_table)) { | 863 | if ((ptr < bplist->data+BPLIST_MAGIC_SIZE+BPLIST_VERSION_SIZE) || (ptr >= bplist->offset_table)) { |
| 858 | PLIST_BIN_ERR("offset for node index %u points outside of valid range\n", node_index); | 864 | PLIST_BIN_ERR("offset for node index %u points outside of valid range\n", node_index); |
