# HG changeset patch # User Carl Byington # Date 1303083070 25200 # Node ID 3f323c867cb4915044240058a815df5868eee94a # Parent 191c1a7e769e76348a397c8b643f580923e0e612 adding more debug code diff -r 191c1a7e769e -r 3f323c867cb4 src/libpst.c --- a/src/libpst.c Sun Apr 17 16:20:04 2011 -0700 +++ b/src/libpst.c Sun Apr 17 16:31:10 2011 -0700 @@ -1339,7 +1339,7 @@ // i_id has been updated to the datablock containing the attachment data attach->i_id = id2_ptr->id->i_id; attach->id2_head = deep_copy(id2_ptr->child); - { + if (attach->data.data) { // fetch the actual data to determine the actual attachment size. pst_index_ll *ptr; pst_binary rc; @@ -1349,12 +1349,14 @@ ptr = pst_getID(pf, attach->i_id); if (ptr) { rc.size = pst_ff_getID2data(pf, ptr, &h); - DEBUG_WARN(("attachment %s size was %#"PRIx64", is now %#"PRIx64" based on size of i_id\n", attach->filename2.str, attach->data.size, rc.size)); - attach->data.size = rc.size; + if (rc.data) free(rc.data); + if (rc.size < attach->data.size) { + 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)); + attach->data.size = rc.size; + } } else { DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n")); } - if (rc.data) free(rc.data); } } else { DEBUG_WARN(("have not located the correct value for the attachment [%#"PRIx64"]\n", attach->id2_val)); diff -r 191c1a7e769e -r 3f323c867cb4 src/readpst.c --- a/src/readpst.c Sun Apr 17 16:20:04 2011 -0700 +++ b/src/readpst.c Sun Apr 17 16:31:10 2011 -0700 @@ -955,7 +955,7 @@ char *attach_filename = (attach->filename2.str) ? attach->filename2.str : attach->filename1.str; DEBUG_ENT("write_separate_attachment"); - DEBUG_INFO(("Attachment %s Size is %"PRIx64", data = %"PRIxPTR", id %#"PRIx64"\n", attach_filename, (uint64_t)attach->data.size, attach->data.data, attach->i_id)); + DEBUG_INFO(("Attachment %s Size is %#"PRIx64", data = %#"PRIxPTR", id %#"PRIx64"\n", attach_filename, (uint64_t)attach->data.size, attach->data.data, attach->i_id)); if (!attach->data.data) { // make sure we can fetch data from the id @@ -1042,9 +1042,8 @@ void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst) { - char *attach_filename; DEBUG_ENT("write_inline_attachment"); - DEBUG_INFO(("Attachment Size is %"PRIx64", data = %"PRIxPTR", id %#"PRIx64"\n", (uint64_t)attach->data.size, attach->data.data, attach->i_id)); + DEBUG_INFO(("Attachment Size is %#"PRIx64", data = %#"PRIxPTR", id %#"PRIx64"\n", (uint64_t)attach->data.size, attach->data.data, attach->i_id)); if (!attach->data.data) { // make sure we can fetch data from the id