comparison src/libpst.c @ 355:d1f930be4711

From Jeffrey Morlan: pst_build_id_ptr and pst_build_desc_ptr require that the first child of a BTree page have the same starting ID as itself. This is not required by the spec, and is not true in many real-world PSTs (presumably, the original first child of the page got deleted). Because of this, many emails are not being extracted from these PSTs. It also triggers an infinite loop in lspst (a separate bug, also fixed)
author Carl Byington <carl@five-ten-sg.com>
date Wed, 06 Jul 2016 10:12:22 -0700
parents 843705c25b45
children fec7f4fca713
comparison
equal deleted inserted replaced
354:843705c25b45 355:d1f930be4711
1041 if (buf) free(buf); 1041 if (buf) free(buf);
1042 DEBUG_RET(); 1042 DEBUG_RET();
1043 return -1; 1043 return -1;
1044 } 1044 }
1045 old = index.id; 1045 old = index.id;
1046 if (x == (int32_t)1) { // first entry
1047 if ((start_val) && (index.id != start_val)) {
1048 DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n"));
1049 if (buf) free(buf);
1050 DEBUG_RET();
1051 return -1;
1052 }
1053 }
1054 i_ptr = (pst_index_ll*) pst_malloc(sizeof(pst_index_ll)); 1046 i_ptr = (pst_index_ll*) pst_malloc(sizeof(pst_index_ll));
1055 i_ptr->i_id = index.id; 1047 i_ptr->i_id = index.id;
1056 i_ptr->offset = index.offset; 1048 i_ptr->offset = index.offset;
1057 i_ptr->u1 = index.u1; 1049 i_ptr->u1 = index.u1;
1058 i_ptr->size = index.size; 1050 i_ptr->size = index.size;
1081 if (buf) free(buf); 1073 if (buf) free(buf);
1082 DEBUG_RET(); 1074 DEBUG_RET();
1083 return -1; 1075 return -1;
1084 } 1076 }
1085 old = table.start; 1077 old = table.start;
1086 if (x == (int32_t)1) { // first entry
1087 if ((start_val) && (table.start != start_val)) {
1088 DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n"));
1089 if (buf) free(buf);
1090 DEBUG_RET();
1091 return -1;
1092 }
1093 }
1094 (void)pst_build_id_ptr(pf, table.offset, depth+1, table.u1, table.start, table2.start); 1078 (void)pst_build_id_ptr(pf, table.offset, depth+1, table.u1, table.start, table2.start);
1095 } 1079 }
1096 } 1080 }
1097 if (buf) free (buf); 1081 if (buf) free (buf);
1098 DEBUG_RET(); 1082 DEBUG_RET();
1155 if (buf) free(buf); 1139 if (buf) free(buf);
1156 DEBUG_RET(); 1140 DEBUG_RET();
1157 return -1; 1141 return -1;
1158 } 1142 }
1159 old = desc_rec.d_id; 1143 old = desc_rec.d_id;
1160 if (x == 0) { // first entry
1161 if (start_val && (desc_rec.d_id != start_val)) {
1162 DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n"));
1163 if (buf) free(buf);
1164 DEBUG_RET();
1165 return -1;
1166 }
1167 }
1168 DEBUG_INFO(("New Record %#"PRIx64" with parent %#x\n", desc_rec.d_id, desc_rec.parent_d_id)); 1144 DEBUG_INFO(("New Record %#"PRIx64" with parent %#x\n", desc_rec.d_id, desc_rec.parent_d_id));
1169 { 1145 {
1170 pst_desc_tree *d_ptr = (pst_desc_tree*) pst_malloc(sizeof(pst_desc_tree)); 1146 pst_desc_tree *d_ptr = (pst_desc_tree*) pst_malloc(sizeof(pst_desc_tree));
1171 d_ptr->d_id = desc_rec.d_id; 1147 d_ptr->d_id = desc_rec.d_id;
1172 d_ptr->parent_d_id = desc_rec.parent_d_id; 1148 d_ptr->parent_d_id = desc_rec.parent_d_id;
1200 if (buf) free(buf); 1176 if (buf) free(buf);
1201 DEBUG_RET(); 1177 DEBUG_RET();
1202 return -1; 1178 return -1;
1203 } 1179 }
1204 old = table.start; 1180 old = table.start;
1205 if (x == 0) { // first entry
1206 if (start_val && (table.start != start_val)) {
1207 DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n"));
1208 if (buf) free(buf);
1209 DEBUG_RET();
1210 return -1;
1211 }
1212 }
1213 (void)pst_build_desc_ptr(pf, table.offset, depth+1, table.u1, table.start, table2.start); 1181 (void)pst_build_desc_ptr(pf, table.offset, depth+1, table.u1, table.start, table2.start);
1214 } 1182 }
1215 } 1183 }
1216 if (buf) free(buf); 1184 if (buf) free(buf);
1217 DEBUG_RET(); 1185 DEBUG_RET();