comparison src/libpst.c @ 370:8700cc322c0c stable-0-6-70

Jeffrey Morlan - pst_getID2 must not recurse into children
author Carl Byington <carl@five-ten-sg.com>
date Wed, 08 Feb 2017 20:43:16 -0800
parents 26c48ea9d896
children 0ccc746c8079
comparison
equal deleted inserted replaced
369:5bd56ffe0759 370:8700cc322c0c
1240 pst_free_list(list); 1240 pst_free_list(list);
1241 1241
1242 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x692))) { 1242 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x692))) {
1243 // DSN/MDN reports? 1243 // DSN/MDN reports?
1244 DEBUG_INFO(("DSN/MDN processing\n")); 1244 DEBUG_INFO(("DSN/MDN processing\n"));
1245 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_head); 1245 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_ptr->child);
1246 if (list) { 1246 if (list) {
1247 for (x=0; x < list->count_objects; x++) { 1247 for (x=0; x < list->count_objects; x++) {
1248 attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach)); 1248 attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach));
1249 memset(attach, 0, sizeof(pst_item_attach)); 1249 memset(attach, 0, sizeof(pst_item_attach));
1250 attach->next = item->attach; 1250 attach->next = item->attach;
1267 } 1267 }
1268 } 1268 }
1269 1269
1270 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x671))) { 1270 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x671))) {
1271 DEBUG_INFO(("ATTACHMENT processing attachment\n")); 1271 DEBUG_INFO(("ATTACHMENT processing attachment\n"));
1272 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_head); 1272 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_ptr->child);
1273 if (!list) { 1273 if (!list) {
1274 if (item->flags & PST_FLAG_HAS_ATTACHMENT) { 1274 if (item->flags & PST_FLAG_HAS_ATTACHMENT) {
1275 // Only report an error if we expected to see an attachment table and didn't. 1275 // Only report an error if we expected to see an attachment table and didn't.
1276 DEBUG_WARN(("ERROR error processing main attachment record\n")); 1276 DEBUG_WARN(("ERROR error processing main attachment record\n"));
1277 } 1277 }
1321 continue; 1321 continue;
1322 } 1322 }
1323 pst_free_list(list); 1323 pst_free_list(list);
1324 // As per 2.4.6.2 in the spec, the attachment data is stored as a child of the 1324 // As per 2.4.6.2 in the spec, the attachment data is stored as a child of the
1325 // attachment object, so we pass in id2_ptr as the head to search from. 1325 // attachment object, so we pass in id2_ptr as the head to search from.
1326 id2_ptr = pst_getID2(id2_ptr, attach->id2_val); 1326 id2_ptr = pst_getID2(id2_ptr->child, attach->id2_val);
1327 if (id2_ptr) { 1327 if (id2_ptr) {
1328 DEBUG_WARN(("second pass attachment updating id2 %#"PRIx64" found i_id %#"PRIx64"\n", attach->id2_val, id2_ptr->id->i_id)); 1328 DEBUG_WARN(("second pass attachment updating id2 %#"PRIx64" found i_id %#"PRIx64"\n", attach->id2_val, id2_ptr->id->i_id));
1329 // i_id has been updated to the datablock containing the attachment data 1329 // i_id has been updated to the datablock containing the attachment data
1330 attach->i_id = id2_ptr->id->i_id; 1330 attach->i_id = id2_ptr->id->i_id;
1331 attach->id2_head = deep_copy(id2_ptr->child); 1331 attach->id2_head = deep_copy(id2_ptr->child);
3635 return ptr; 3635 return ptr;
3636 } 3636 }
3637 3637
3638 3638
3639 static pst_id2_tree *pst_getID2(pst_id2_tree *head, uint64_t id2) { 3639 static pst_id2_tree *pst_getID2(pst_id2_tree *head, uint64_t id2) {
3640 // the id2 values are only unique among siblings.
3641 // we must not recurse into children
3642 // the caller must supply the correct parent
3640 DEBUG_ENT("pst_getID2"); 3643 DEBUG_ENT("pst_getID2");
3641 DEBUG_INFO(("looking for id2 = %#"PRIx64"\n", id2)); 3644 DEBUG_INFO(("looking for id2 = %#"PRIx64"\n", id2));
3642 pst_id2_tree *ptr = head; 3645 pst_id2_tree *ptr = head;
3643 while (ptr) { 3646 while (ptr) {
3644 if (ptr->id2 == id2) break; 3647 if (ptr->id2 == id2) break;
3645 if (ptr->child) {
3646 pst_id2_tree *rc = pst_getID2(ptr->child, id2);
3647 if (rc) {
3648 DEBUG_RET();
3649 return rc;
3650 }
3651 }
3652 ptr = ptr->next; 3648 ptr = ptr->next;
3653 } 3649 }
3654 if (ptr && ptr->id) { 3650 if (ptr && ptr->id) {
3655 DEBUG_INFO(("Found value %#"PRIx64"\n", ptr->id->i_id)); 3651 DEBUG_INFO(("Found value %#"PRIx64"\n", ptr->id->i_id));
3656 DEBUG_RET(); 3652 DEBUG_RET();