comparison src/libpst.c @ 40:be6d5329cc01 stable-0-5-11

fix unitialized variable
author carl
date Fri, 24 Aug 2007 18:57:59 -0700
parents 2ad7ef0a3c4f
children 183ae993b9ad
comparison
equal deleted inserted replaced
39:2ad7ef0a3c4f 40:be6d5329cc01
269 if (c) { 269 if (c) {
270 pst_fwrite(c, 1, strlen(c), fp); 270 pst_fwrite(c, 1, strlen(c), fp);
271 free(c); // caught by valgrind 271 free(c); // caught by valgrind
272 } 272 }
273 } else { 273 } else {
274 DEBUG_WARN (("Couldn't find ID pointer. Cannot save attachement to Base64\n")); 274 DEBUG_WARN (("Couldn't find ID pointer. Cannot save attachment to Base64\n"));
275 size = 0; 275 size = 0;
276 } 276 }
277 attach->size = size; 277 attach->size = size;
278 } else { 278 } else {
279 // encode the attachment to the file 279 // encode the attachment to the file
336 336
337 int32_t pst_load_extended_attributes(pst_file *pf) { 337 int32_t pst_load_extended_attributes(pst_file *pf) {
338 // for PST files this will load up ID2 0x61 and check it's "list" attribute. 338 // for PST files this will load up ID2 0x61 and check it's "list" attribute.
339 pst_desc_ll *p; 339 pst_desc_ll *p;
340 pst_num_array *na; 340 pst_num_array *na;
341 pst_index2_ll *list2; 341 pst_index2_ll *list2 = NULL;
342 unsigned char * buffer=NULL, *headerbuffer=NULL;//, *tc; 342 unsigned char * buffer=NULL, *headerbuffer=NULL;//, *tc;
343 pst_x_attrib xattrib; 343 pst_x_attrib xattrib;
344 int32_t bptr = 0, bsize, hsize, tint, err=0, x; 344 int32_t bptr = 0, bsize, hsize, tint, err=0, x;
345 pst_x_attrib_ll *ptr, *p_head=NULL, *p_sh=NULL, *p_sh2=NULL; 345 pst_x_attrib_ll *ptr, *p_head=NULL, *p_sh=NULL, *p_sh2=NULL;
346 346
348 if ((p = _pst_getDptr(pf, 0x61)) == NULL) { 348 if ((p = _pst_getDptr(pf, 0x61)) == NULL) {
349 DEBUG_WARN(("Cannot find DescID 0x61 for loading the Extended Attributes\n")); 349 DEBUG_WARN(("Cannot find DescID 0x61 for loading the Extended Attributes\n"));
350 DEBUG_RET(); 350 DEBUG_RET();
351 return 0; 351 return 0;
352 } 352 }
353 if (p->list_index) { 353
354 list2 = _pst_build_id2(pf, p->list_index, NULL);
355 }
356 if (!p->desc) { 354 if (!p->desc) {
357 DEBUG_WARN(("desc is NULL for item 0x61. Cannot load Extended Attributes\n")); 355 DEBUG_WARN(("desc is NULL for item 0x61. Cannot load Extended Attributes\n"));
358 DEBUG_RET(); 356 DEBUG_RET();
359 return 0; 357 return 0;
360 } 358 }
361 if ((na = _pst_parse_block(pf, p->desc->id, list2)) == NULL) { 359
360 if (p->list_index) {
361 list2 = _pst_build_id2(pf, p->list_index, NULL);
362 _pst_printID2ptr(list2);
363 } else {
364 DEBUG_WARN(("Have not been able to fetch any id2 values for item 0x61. Brace yourself!\n"));
365 }
366
367 na = _pst_parse_block(pf, p->desc->id, list2);
368 if (!na) {
362 DEBUG_WARN(("Cannot process desc block for item 0x61. Not loading extended Attributes\n")); 369 DEBUG_WARN(("Cannot process desc block for item 0x61. Not loading extended Attributes\n"));
370 if (list2) _pst_free_id2(list2);
363 DEBUG_RET(); 371 DEBUG_RET();
364 return 0; 372 return 0;
365 } 373 }
374
366 x = 0; 375 x = 0;
367 while (x < na->count_item) { 376 while (x < na->count_item) {
368 if (na->items[x]->id == 0x0003) { 377 if (na->items[x]->id == 0x0003) {
369 buffer = na->items[x]->data; 378 buffer = na->items[x]->data;
370 bsize = na->items[x]->size; 379 bsize = na->items[x]->size;
934 DEBUG_WARN(("you cannot pass me a NULL! I don't want it!\n")); 943 DEBUG_WARN(("you cannot pass me a NULL! I don't want it!\n"));
935 DEBUG_RET(); 944 DEBUG_RET();
936 return NULL; 945 return NULL;
937 } 946 }
938 947
948 if (!d_ptr->desc) {
949 DEBUG_WARN(("why is d_ptr->desc == NULL? I don't want to do anything else with this record\n"));
950 DEBUG_RET();
951 return NULL;
952 }
953
939 if (d_ptr->list_index) { 954 if (d_ptr->list_index) {
940 id2_head = _pst_build_id2(pf, d_ptr->list_index, NULL); 955 id2_head = _pst_build_id2(pf, d_ptr->list_index, NULL);
941 _pst_printID2ptr(id2_head); 956 _pst_printID2ptr(id2_head);
942 } else { 957 } else {
943 DEBUG_WARN(("Have not been able to fetch any id2 values for this item. Brace yourself!\n")); 958 DEBUG_WARN(("Have not been able to fetch any id2 values for this item. Brace yourself!\n"));
944 } 959 }
945 960
946 if (!d_ptr->desc) { 961 list = _pst_parse_block(pf, d_ptr->desc->id, id2_head);
947 DEBUG_WARN(("why is d_ptr->desc == NULL? I don't want to do anything else with this record\n")); 962 if (!list) {
948 if (id2_head) _pst_free_id2(id2_head);
949 DEBUG_RET();
950 return NULL;
951 }
952
953 if ((list = _pst_parse_block(pf, d_ptr->desc->id, id2_head)) == NULL) {
954 DEBUG_WARN(("_pst_parse_block() returned an error for d_ptr->desc->id [%#x]\n", d_ptr->desc->id)); 963 DEBUG_WARN(("_pst_parse_block() returned an error for d_ptr->desc->id [%#x]\n", d_ptr->desc->id));
955 if (id2_head) _pst_free_id2(id2_head); 964 if (id2_head) _pst_free_id2(id2_head);
956 DEBUG_RET(); 965 DEBUG_RET();
957 return NULL; 966 return NULL;
958 } 967 }
970 } 979 }
971 if (list) _pst_free_list(list); 980 if (list) _pst_free_list(list);
972 list = NULL; //_pst_process will free the items in the list 981 list = NULL; //_pst_process will free the items in the list
973 982
974 if ((id_ptr = _pst_getID2(id2_head, 0x671))) { 983 if ((id_ptr = _pst_getID2(id2_head, 0x671))) {
975 // attachements exist - so we will process them 984 // attachments exist - so we will process them
976 while (item->attach) { 985 while (item->attach) {
977 attach = item->attach->next; 986 attach = item->attach->next;
978 free(item->attach); 987 free(item->attach);
979 item->attach = attach; 988 item->attach = attach;
980 } 989 }
981 990
982 DEBUG_EMAIL(("ATTACHEMENT processing attachement\n")); 991 DEBUG_EMAIL(("ATTACHMENT processing attachment\n"));
983 if ((list = _pst_parse_block(pf, id_ptr->id, id2_head)) == NULL) { 992 if ((list = _pst_parse_block(pf, id_ptr->id, id2_head)) == NULL) {
984 DEBUG_WARN(("ERROR error processing main attachment record\n")); 993 DEBUG_WARN(("ERROR error processing main attachment record\n"));
985 if (item) _pst_freeItem(item); 994 if (item) _pst_freeItem(item);
986 if (id2_head) _pst_free_id2(id2_head); 995 if (id2_head) _pst_free_id2(id2_head);
987 DEBUG_RET(); 996 DEBUG_RET();
2213 // 2 - Attach by reference 2222 // 2 - Attach by reference
2214 // 3 - Attach by ref resolve 2223 // 3 - Attach by ref resolve
2215 // 4 - Attach by ref only 2224 // 4 - Attach by ref only
2216 // 5 - Embedded Message 2225 // 5 - Embedded Message
2217 // 6 - OLE 2226 // 6 - OLE
2218 DEBUG_EMAIL(("Attachement method - ")); 2227 DEBUG_EMAIL(("Attachment method - "));
2219 NULL_CHECK(attach); 2228 NULL_CHECK(attach);
2220 MOVE_NEXT(attach); 2229 MOVE_NEXT(attach);
2221 memcpy(&(attach->method), list->items[x]->data, sizeof(attach->method)); 2230 memcpy(&(attach->method), list->items[x]->data, sizeof(attach->method));
2222 LE32_CPU(attach->method); 2231 LE32_CPU(attach->method);
2223 t = attach->method; 2232 t = attach->method;