changeset 266:3f323c867cb4

adding more debug code
author Carl Byington <carl@five-ten-sg.com>
date Sun, 17 Apr 2011 16:31:10 -0700
parents 191c1a7e769e
children 3fa737c05322
files src/libpst.c src/readpst.c
diffstat 2 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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));
--- 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