comparison src/libpst.c @ 41:183ae993b9ad

security fix for potential buffer overrun in lz decompress
author carl
date Tue, 02 Oct 2007 15:49:44 -0700
parents be6d5329cc01
children f6db1f060a95
comparison
equal deleted inserted replaced
40:be6d5329cc01 41:183ae993b9ad
1492 #define MALLOC_FOLDER(x) { if (!x->folder) { x->folder = (pst_item_folder*) xmalloc(sizeof(pst_item_folder)); memset(x->folder, 0, sizeof(pst_item_folder) );} } 1492 #define MALLOC_FOLDER(x) { if (!x->folder) { x->folder = (pst_item_folder*) xmalloc(sizeof(pst_item_folder)); memset(x->folder, 0, sizeof(pst_item_folder) );} }
1493 #define MALLOC_CONTACT(x) { if (!x->contact) { x->contact = (pst_item_contact*) xmalloc(sizeof(pst_item_contact)); memset(x->contact, 0, sizeof(pst_item_contact) );} } 1493 #define MALLOC_CONTACT(x) { if (!x->contact) { x->contact = (pst_item_contact*) xmalloc(sizeof(pst_item_contact)); memset(x->contact, 0, sizeof(pst_item_contact) );} }
1494 #define MALLOC_MESSAGESTORE(x) { if (!x->message_store) { x->message_store = (pst_item_message_store*) xmalloc(sizeof(pst_item_message_store)); memset(x->message_store, 0, sizeof(pst_item_message_store));} } 1494 #define MALLOC_MESSAGESTORE(x) { if (!x->message_store) { x->message_store = (pst_item_message_store*) xmalloc(sizeof(pst_item_message_store)); memset(x->message_store, 0, sizeof(pst_item_message_store));} }
1495 #define MALLOC_JOURNAL(x) { if (!x->journal) { x->journal = (pst_item_journal*) xmalloc(sizeof(pst_item_journal)); memset(x->journal, 0, sizeof(pst_item_journal) );} } 1495 #define MALLOC_JOURNAL(x) { if (!x->journal) { x->journal = (pst_item_journal*) xmalloc(sizeof(pst_item_journal)); memset(x->journal, 0, sizeof(pst_item_journal) );} }
1496 #define MALLOC_APPOINTMENT(x) { if (!x->appointment) { x->appointment = (pst_item_appointment*) xmalloc(sizeof(pst_item_appointment)); memset(x->appointment, 0, sizeof(pst_item_appointment) );} } 1496 #define MALLOC_APPOINTMENT(x) { if (!x->appointment) { x->appointment = (pst_item_appointment*) xmalloc(sizeof(pst_item_appointment)); memset(x->appointment, 0, sizeof(pst_item_appointment) );} }
1497 // malloc space and copy the current item's data -- plus one on the size for good luck (and string termination) 1497 // malloc space and copy the current item's data null terminated
1498 #define LIST_COPY(targ, type) { \ 1498 #define LIST_COPY(targ, type) { \
1499 targ = type realloc(targ, list->items[x]->size+1); \ 1499 targ = type realloc(targ, list->items[x]->size+1); \
1500 memset(targ, 0, list->items[x]->size+1); \
1501 memcpy(targ, list->items[x]->data, list->items[x]->size); \ 1500 memcpy(targ, list->items[x]->data, list->items[x]->size); \
1501 memset(((char*)targ)+list->items[x]->size, 0, 1); \
1502 }
1503 // malloc space and copy the current item's data and size
1504 #define LIST_COPY_SIZE(targ, type, mysize) { \
1505 mysize = list->items[x]->size; \
1506 targ = type realloc(targ, mysize); \
1507 memcpy(targ, list->items[x]->data, mysize); \
1502 } 1508 }
1503 1509
1504 #define NULL_CHECK(x) { if (!x) { DEBUG_EMAIL(("NULL_CHECK: Null Found\n")); break;} } 1510 #define NULL_CHECK(x) { if (!x) { DEBUG_EMAIL(("NULL_CHECK: Null Found\n")); break;} }
1505 1511
1506 #define MOVE_NEXT(targ) { \ 1512 #define MOVE_NEXT(targ) { \
2024 case 0x1009: // PR_RTF_COMPRESSED 2030 case 0x1009: // PR_RTF_COMPRESSED
2025 // some compression algorithm has been applied to this. At present 2031 // some compression algorithm has been applied to this. At present
2026 // it is unknown 2032 // it is unknown
2027 DEBUG_EMAIL(("RTF Compressed body - ")); 2033 DEBUG_EMAIL(("RTF Compressed body - "));
2028 MALLOC_EMAIL(item); 2034 MALLOC_EMAIL(item);
2029 LIST_COPY(item->email->rtf_compressed, (char*)); 2035 LIST_COPY_SIZE(item->email->rtf_compressed, (char*), item->email->rtf_compressed_size);
2030 DEBUG_EMAIL(("NOT PRINTED\n")); 2036 DEBUG_EMAIL(("NOT PRINTED\n"));
2031 break; 2037 break;
2032 case 0x1010: // PR_RTF_SYNC_PREFIX_COUNT 2038 case 0x1010: // PR_RTF_SYNC_PREFIX_COUNT
2033 // a count of the ignored characters before the first significant character 2039 // a count of the ignored characters before the first significant character
2034 DEBUG_EMAIL(("RTF whitespace prefix count - ")); 2040 DEBUG_EMAIL(("RTF whitespace prefix count - "));