# HG changeset patch # User carl # Date 1186758373 25200 # Node ID ddfb25318812f98ff35380b46c292819f42aa385 # Parent 6fe121a971c9292ec2d30024e63a2cd127d7bb57 more valgrind fixes diff -r 6fe121a971c9 -r ddfb25318812 AUTHORS --- a/AUTHORS Thu Aug 09 15:46:34 2007 -0700 +++ b/AUTHORS Fri Aug 10 08:06:13 2007 -0700 @@ -1,7 +1,8 @@ Dave Smith With contributions by: - Joseph Nahmias + Joseph Nahmias -- bounces + Joseph Nahmias Carl Byington Arne Ahrend Nigel Horne diff -r 6fe121a971c9 -r ddfb25318812 ChangeLog --- a/ChangeLog Thu Aug 09 15:46:34 2007 -0700 +++ b/ChangeLog Fri Aug 10 08:06:13 2007 -0700 @@ -1,3 +1,11 @@ +LibPST 0.5.8 (2007-08-10) +=============================== + + * fix more valgrind errors. lzfu_decompress needs to return the + actual buffer size, since the lz header overestimates the size. + This caused base64_encode to encode undefined bytes into the + email attachment. + LibPST 0.5.7 (2007-08-09) =============================== diff -r 6fe121a971c9 -r ddfb25318812 configure.in --- a/configure.in Thu Aug 09 15:46:34 2007 -0700 +++ b/configure.in Fri Aug 10 08:06:13 2007 -0700 @@ -1,7 +1,7 @@ AC_INIT(configure.in) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libpst,0.5.7) +AM_INIT_AUTOMAKE(libpst,0.5.8) AC_PATH_PROGS(BASH, bash) AC_LANG_CPLUSPLUS diff -r 6fe121a971c9 -r ddfb25318812 src/debug.c --- a/src/debug.c Thu Aug 09 15:46:34 2007 -0700 +++ b/src/debug.c Fri Aug 10 08:06:13 2007 -0700 @@ -321,7 +321,7 @@ fseek(debug_fp, 0, SEEK_END); item_ptr = item_head = item_tail = NULL; free(index); - if (buf) free(buf); buf = NULL; + if (buf) free(buf); } @@ -330,7 +330,7 @@ struct _debug_file_rec_m mfile_rec; unsigned char rec_type; int index_size = 3 * sizeof(int); - int *index = malloc(index_size); + int index[3]; int index_pos, file_pos; char zero='\0'; unsigned int end; @@ -381,7 +381,6 @@ fwrite(&mfile_rec, sizeof(mfile_rec), 1, debug_fp); } fseek(debug_fp, 0, SEEK_END); - // that should do it... } @@ -389,10 +388,9 @@ struct _debug_file_rec_l lfile_rec; unsigned char rec_type; int index_size = 3 * sizeof(int); - int index_pos, file_pos, *index; + int index_pos, file_pos, index[3]; char zero='\0'; if (!debug_fp) return; // no file - index = malloc(index_size); index[0] = 1; // only one item in this index run index[1] = 0; // valgrind, avoid writing uninitialized data index[2] = 0; // "" @@ -434,7 +432,7 @@ fprintf(stderr, "xMalloc: Out Of memory [req: %ld]\n", (long)size); exit(1); } - memset(mem, 0, size); // valgrind, some email attachment does not initialize the entire buffer passed to base64 encode + //memset(mem, 0, size); // valgrind return mem; } diff -r 6fe121a971c9 -r ddfb25318812 src/lzfu.c --- a/src/lzfu.c Thu Aug 09 15:46:34 2007 -0700 +++ b/src/lzfu.c Fri Aug 10 08:06:13 2007 -0700 @@ -69,8 +69,10 @@ memcpy(dict, LZFU_INITDICT, LZFU_INITLENGTH); dict_length = LZFU_INITLENGTH; memcpy(&lzfuhdr, rtfcomp, sizeof(lzfuhdr)); - LE32_CPU(lzfuhdr.cbSize); LE32_CPU(lzfuhdr.cbRawSize); - LE32_CPU(lzfuhdr.dwMagic); LE32_CPU(lzfuhdr.dwCRC); + LE32_CPU(lzfuhdr.cbSize); + LE32_CPU(lzfuhdr.cbRawSize); + LE32_CPU(lzfuhdr.dwMagic); + LE32_CPU(lzfuhdr.dwCRC); /* printf("total size: %d\n", lzfuhdr.cbSize+4); printf("raw size : %d\n", lzfuhdr.cbRawSize); printf("compressed: %s\n", (lzfuhdr.dwMagic == LZFU_COMPRESSED ? "yes" : "no")); @@ -122,7 +124,7 @@ // we should do that out_buf[out_ptr++] = '}'; out_buf[out_ptr++] = '}'; + *size = out_ptr; out_buf[out_ptr++] = '\0'; - *size = out_ptr; return out_buf; } diff -r 6fe121a971c9 -r ddfb25318812 src/readpst.c --- a/src/readpst.c Thu Aug 09 15:46:34 2007 -0700 +++ b/src/readpst.c Fri Aug 10 08:06:13 2007 -0700 @@ -291,10 +291,9 @@ item = _pst_parse_item(&pstfile, d_ptr); DEBUG_MAIN(("main: About to process item\n")); - if (item && item->email && item->email->subject && - item->email->subject->subj) { - // DEBUG_EMAIL(("item->email->subject = %p\n", item->email->subject)); - // DEBUG_EMAIL(("item->email->subject->subj = %p\n", item->email->subject->subj)); + if (item && item->email && item->email->subject && item->email->subject->subj) { + DEBUG_EMAIL(("item->email->subject = %p\n", item->email->subject)); + DEBUG_EMAIL(("item->email->subject->subj = %p\n", item->email->subject->subj)); } if (item) { if (item->message_store) { @@ -341,7 +340,7 @@ f = head; } _pst_freeItem(item); - item = NULL; // just for the odd situations! + item = NULL; goto check_parent; } else if (item->contact) { // deal with a contact @@ -432,8 +431,7 @@ while (!skip_child && !d_ptr->next && d_ptr->parent) { DEBUG_MAIN(("main: Going to Parent\n")); head = f->next; - if (f->output) - fclose(f->output); + if (f->output) fclose(f->output); DEBUG_MAIN(("main: Email Count for folder %s is %i\n", f->dname, f->email_count)); if (output_mode != OUTPUT_QUIET) printf("\t\"%s\" - %i items done, skipped %i, should have been %i\n", @@ -477,8 +475,7 @@ pst_close(&pstfile); // fclose(pstfile.fp); while (f) { - if (f->output) - fclose(f->output); + if (f->output) fclose(f->output); free(f->name); free(f->dname); @@ -1236,6 +1233,7 @@ } if (item->email->rtf_compressed && save_rtf) { + //int32_t tester; DEBUG_EMAIL(("Adding RTF body as attachment\n")); current_attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach)); memset(current_attach, 0, sizeof(pst_item_attach)); @@ -1246,8 +1244,9 @@ strcpy(current_attach->filename2, RTF_ATTACH_NAME); current_attach->mimetype = xmalloc(strlen(RTF_ATTACH_TYPE)+2); strcpy(current_attach->mimetype, RTF_ATTACH_TYPE); - memcpy(&(current_attach->size), item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); - LE32_CPU(current_attach->size); + //memcpy(&tester, item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); + //LE32_CPU(tester); + //printf("lz produced %d bytes, rtf claims %d bytes\n", current_attach->size, tester); } if (item->email->encrypted_body || item->email->encrypted_htmlbody) { @@ -1307,7 +1306,7 @@ fprintf(f_output, "BEGIN:VCARD\n"); fprintf(f_output, "FN:%s\n", rfc2426_escape(contact->fullname)); fprintf(f_output, "N:%s;%s;%s;%s;%s\n", - (!contact->surname) ? "" : rfc2426_escape(contact->surname), + (!contact->surname) ? "" : rfc2426_escape(contact->surname), (!contact->first_name) ? "" : rfc2426_escape(contact->first_name), (!contact->middle_name) ? "" : rfc2426_escape(contact->middle_name), (!contact->display_name_prefix) ? "" : rfc2426_escape(contact->display_name_prefix), @@ -1336,17 +1335,17 @@ if (contact->business_address) { // these should be equivalent, but valgrind complains about the single large fprintf // - char *ab = (!contact->business_po_box ) ? "" : rfc2426_escape(contact->business_po_box ); - char *ac = (!contact->business_street ) ? "" : rfc2426_escape(contact->business_street ); - char *ad = (!contact->business_city ) ? "" : rfc2426_escape(contact->business_city ); - char *ae = (!contact->business_state ) ? "" : rfc2426_escape(contact->business_state ); - char *af = (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code); - char *ag = (!contact->business_country ) ? "" : rfc2426_escape(contact->business_country ); + char *ab = (!contact->business_po_box ) ? "" : rfc2426_escape(contact->business_po_box ); + char *ac = (!contact->business_street ) ? "" : rfc2426_escape(contact->business_street ); + char *ad = (!contact->business_city ) ? "" : rfc2426_escape(contact->business_city ); + char *ae = (!contact->business_state ) ? "" : rfc2426_escape(contact->business_state ); + char *af = (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code); + char *ag = (!contact->business_country ) ? "" : rfc2426_escape(contact->business_country ); fprintf(f_output, "ADR;TYPE=work:%s;%s;%s;%s;%s;%s;%s\n", ab, "", ac, ad, ae, af, ag); //fprintf(f_output, "ADR;TYPE=work:%s;%s;%s;%s;%s;%s;%s\n", - // (!contact->business_po_box) ? "" : rfc2426_escape(contact->business_po_box), + // (!contact->business_po_box) ? "" : rfc2426_escape(contact->business_po_box), // "", // extended Address - // (!contact->business_street) ? "" : rfc2426_escape(contact->business_street), + // (!contact->business_street) ? "" : rfc2426_escape(contact->business_street), // (!contact->business_city) ? "" : rfc2426_escape(contact->business_city), // (!contact->business_state) ? "" : rfc2426_escape(contact->business_state), // (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code),