comparison src/libpst.c @ 269:5ca87faa020b

attachment might have a secondary list of mapi elements included a size element which overwrote the real size from the primary list of mapi elements
author Carl Byington <carl@five-ten-sg.com>
date Sun, 17 Apr 2011 18:45:33 -0700
parents 8dcfef53a4f3
children eafaf362779e
comparison
equal deleted inserted replaced
268:8dcfef53a4f3 269:5ca87faa020b
1325 continue; 1325 continue;
1326 } 1326 }
1327 if (list->count_objects > 1) { 1327 if (list->count_objects > 1) {
1328 DEBUG_WARN(("ERROR probably fatal, list count array will overrun attach structure.\n")); 1328 DEBUG_WARN(("ERROR probably fatal, list count array will overrun attach structure.\n"));
1329 } 1329 }
1330 // reprocess the same attachment list against new data
1331 // this might update attach->id2_val
1330 if (pst_process(list, item, attach)) { 1332 if (pst_process(list, item, attach)) {
1331 DEBUG_WARN(("ERROR pst_process() failed with an attachment\n")); 1333 DEBUG_WARN(("ERROR pst_process() failed with an attachment\n"));
1332 pst_free_list(list); 1334 pst_free_list(list);
1333 continue; 1335 continue;
1334 } 1336 }
1337 if (id2_ptr) { 1339 if (id2_ptr) {
1338 DEBUG_WARN(("second pass attachment updating id2 %#"PRIx64" found i_id %#"PRIx64"\n", attach->id2_val, id2_ptr->id->i_id)); 1340 DEBUG_WARN(("second pass attachment updating id2 %#"PRIx64" found i_id %#"PRIx64"\n", attach->id2_val, id2_ptr->id->i_id));
1339 // i_id has been updated to the datablock containing the attachment data 1341 // i_id has been updated to the datablock containing the attachment data
1340 attach->i_id = id2_ptr->id->i_id; 1342 attach->i_id = id2_ptr->id->i_id;
1341 attach->id2_head = deep_copy(id2_ptr->child); 1343 attach->id2_head = deep_copy(id2_ptr->child);
1342 if (attach->data.data) {
1343 // fetch the actual data to determine the actual attachment size.
1344 pst_index_ll *ptr;
1345 pst_binary rc;
1346 pst_holder h = {&rc.data, NULL, 0, 0, 0};
1347 rc.size = 0;
1348 rc.data = NULL;
1349 ptr = pst_getID(pf, attach->i_id);
1350 if (ptr) {
1351 rc.size = pst_ff_getID2data(pf, ptr, &h);
1352 if (rc.data) free(rc.data);
1353 if (rc.size < attach->data.size) {
1354 DEBUG_WARN(("reducing attachment %s size was %#"PRIx64", is now %#"PRIx64" based on size of i_id\n", attach->filename2.str, attach->data.size, rc.size));
1355 attach->data.size = rc.size;
1356 }
1357 } else {
1358 DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n"));
1359 }
1360 }
1361 } else { 1344 } else {
1362 DEBUG_WARN(("have not located the correct value for the attachment [%#"PRIx64"]\n", attach->id2_val)); 1345 DEBUG_WARN(("have not located the correct value for the attachment [%#"PRIx64"]\n", attach->id2_val));
1363 } 1346 }
1364 } else { 1347 } else {
1365 DEBUG_WARN(("ERROR cannot locate id2 value %#"PRIx64"\n", attach->id2_val)); 1348 DEBUG_WARN(("ERROR cannot locate id2 value %#"PRIx64"\n", attach->id2_val));
2465 LIST_COPY_EMAIL_BOOL("Compressed RTF in Sync", item->email->rtf_in_sync); 2448 LIST_COPY_EMAIL_BOOL("Compressed RTF in Sync", item->email->rtf_in_sync);
2466 break; 2449 break;
2467 case 0x0E20: // PR_ATTACH_SIZE binary Attachment data in record 2450 case 0x0E20: // PR_ATTACH_SIZE binary Attachment data in record
2468 NULL_CHECK(attach); 2451 NULL_CHECK(attach);
2469 LIST_COPY_INT32("Attachment Size", t); 2452 LIST_COPY_INT32("Attachment Size", t);
2470 if (attach->data.data && (attach->data.size != (size_t)t)) { 2453 // ignore this. we either get data and size from 0x3701
2471 DEBUG_INFO(("already have data %#"PRIxPTR" size %#"PRIx64"\n", attach->data.data, attach->data.size)); 2454 // or id codes from 0x3701 or 0x67f2
2472 }
2473 else {
2474 attach->data.size = (size_t)t;
2475 }
2476 break; 2455 break;
2477 case 0x0FF9: // PR_RECORD_KEY Record Header 1 2456 case 0x0FF9: // PR_RECORD_KEY Record Header 1
2478 LIST_COPY_BIN(item->record_key); 2457 LIST_COPY_BIN(item->record_key);
2479 DEBUG_INFO(("Record Key\n")); 2458 DEBUG_INFO(("Record Key\n"));
2480 DEBUG_HEXDUMP(item->record_key.data, item->record_key.size); 2459 DEBUG_HEXDUMP(item->record_key.data, item->record_key.size);