summaryrefslogtreecommitdiffstats
path: root/src/bplist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bplist.c')
-rw-r--r--src/bplist.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/bplist.c b/src/bplist.c
index 2e32f70..a73f1ee 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -447,10 +447,11 @@ static plist_t parse_dict_node(struct bplist_data *bplist, const char** bnode, u
447static plist_t parse_array_node(struct bplist_data *bplist, const char** bnode, uint64_t size) 447static plist_t parse_array_node(struct bplist_data *bplist, const char** bnode, uint64_t size)
448{ 448{
449 uint64_t j; 449 uint64_t j;
450 uint32_t str_j = 0; 450 uint64_t str_j = 0;
451 uint32_t index1; 451 uint64_t index1;
452
453 plist_data_t data = plist_new_plist_data(); 452 plist_data_t data = plist_new_plist_data();
453 const char *const end_data = bplist->data + bplist->size;
454 const char *index1_ptr = NULL;
454 455
455 data->type = PLIST_ARRAY; 456 data->type = PLIST_ARRAY;
456 data->length = size; 457 data->length = size;
@@ -459,7 +460,14 @@ static plist_t parse_array_node(struct bplist_data *bplist, const char** bnode,
459 460
460 for (j = 0; j < data->length; j++) { 461 for (j = 0; j < data->length; j++) {
461 str_j = j * bplist->ref_size; 462 str_j = j * bplist->ref_size;
462 index1 = UINT_TO_HOST((*bnode) + str_j, bplist->ref_size); 463 index1_ptr = (*bnode) + str_j;
464
465 if (index1_ptr < bplist->data || index1_ptr + bplist->ref_size >= end_data) {
466 plist_free(node);
467 return NULL;
468 }
469
470 index1 = UINT_TO_HOST(index1_ptr, bplist->ref_size);
463 471
464 if (index1 >= bplist->num_objects) { 472 if (index1 >= bplist->num_objects) {
465 plist_free(node); 473 plist_free(node);