summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Filippo Bigarella2016-11-10 01:24:29 +0100
committerGravatar Nikias Bassen2016-11-10 01:24:29 +0100
commit1ae55728f427532234be85a90322e4a3c77b4074 (patch)
tree55dfe72ec6ea98b2eb7a7a9e8c12ebbe03cbe7ab /src
parentb86a392b819518cf37db78140d4ed4418c0177da (diff)
downloadlibplist-1ae55728f427532234be85a90322e4a3c77b4074.tar.gz
libplist-1ae55728f427532234be85a90322e4a3c77b4074.tar.bz2
bplist: Make sure the index in parse_bin_node_at_index() is actually within the offset table
Diffstat (limited to 'src')
-rw-r--r--src/bplist.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/bplist.c b/src/bplist.c
index dad72a6..8447187 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -661,11 +661,20 @@ static plist_t parse_bin_node(struct bplist_data *bplist, const char** object)
661 661
662static plist_t parse_bin_node_at_index(struct bplist_data *bplist, uint32_t node_index) 662static plist_t parse_bin_node_at_index(struct bplist_data *bplist, uint32_t node_index)
663{ 663{
664 int i; 664 int i = 0;
665 const char* ptr; 665 const char* ptr = NULL;
666 plist_t plist; 666 plist_t plist = NULL;
667 const char* idx_ptr = NULL;
667 668
668 ptr = bplist->data + UINT_TO_HOST(bplist->offset_table + node_index * bplist->offset_size, bplist->offset_size); 669 if (node_index > bplist->num_objects)
670 return NULL;
671
672 idx_ptr = bplist->offset_table + node_index * bplist->offset_size;
673 if (idx_ptr < bplist->offset_table ||
674 idx_ptr >= bplist->offset_table + bplist->num_objects * bplist->offset_size)
675 return NULL;
676
677 ptr = bplist->data + UINT_TO_HOST(idx_ptr, bplist->offset_size);
669 /* make sure the node offset is in a sane range */ 678 /* make sure the node offset is in a sane range */
670 if ((ptr < bplist->data) || (ptr >= bplist->offset_table)) { 679 if ((ptr < bplist->data) || (ptr >= bplist->offset_table)) {
671 return NULL; 680 return NULL;