Skip to content
Snippets Groups Projects
Commit 3b6fa5ba authored by Brian Carrier's avatar Brian Carrier
Browse files

refactor - no code chnages

parent 95e08ecb
No related branches found
No related tags found
No related merge requests found
......@@ -58,31 +58,32 @@ tsk_vs_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset,
* will not be reported
*/
if (type == TSK_VS_TYPE_DETECT) {
TSK_VS_INFO *vs, *vs_set = NULL;
char *set = NULL;
TSK_VS_INFO *vs, *prev_vs = NULL;
char *prev_type = NULL;
if ((vs = tsk_vs_dos_open(img_info, offset, 1)) != NULL) {
set = "DOS";
vs_set = vs;
prev_type = "DOS";
prev_vs = vs;
}
else {
tsk_error_reset();
}
if ((vs = tsk_vs_bsd_open(img_info, offset)) != NULL) {
// if (set == NULL) {
// if (prev_type == NULL) {
// In this case, BSD takes priority because BSD partitions start off with
// the DOS magic value in the first sector with the boot code.
set = "BSD";
vs_set = vs;
prev_type = "BSD";
prev_vs = vs;
/*
}
else {
vs_set->close(vs_set);
prev_vs->close(prev_vs);
vs->close(vs);
tsk_error_reset();
tsk_error_set_errno(TSK_ERR_VS_UNKTYPE);
tsk_error_set_errstr(
"BSD or %s at %" PRIuDADDR, set, offset);
"BSD or %s at %" PRIuDADDR, prev_type, offset);
tsk_errstr2[0] = '\0';
return NULL;
}
......@@ -91,24 +92,26 @@ tsk_vs_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset,
else {
tsk_error_reset();
}
if ((vs = tsk_vs_gpt_open(img_info, offset)) != NULL) {
if ((set != NULL) && (strcmp(set, "DOS") == 0) && (vs->is_backup)) {
if ((prev_type != NULL) && (strcmp(prev_type, "DOS") == 0) && (vs->is_backup)) {
/* In this case we've found a DOS partition and a backup GPT partition.
* The DOS partition takes priority in this case (and are already in set and vs_set) */
* The DOS partition takes priority in this case (and are already in prev_type and prev_vs) */
vs->close(vs);
if (tsk_verbose)
tsk_fprintf(stderr,
"mm_open: Ignoring secondary GPT Partition\n");
}
else {
if (set != NULL) {
if (prev_type != NULL) {
/* GPT drives have a DOS Safety partition table.
* Test to see if we can ignore one */
if (strcmp(set, "DOS") == 0) {
* Test to see if the GPT has a safety partiiton
* and then we can igore the DOS */
if (strcmp(prev_type, "DOS") == 0) {
TSK_VS_PART_INFO *tmp_set;
for (tmp_set = vs_set->part_list; tmp_set;
for (tmp_set = prev_vs->part_list; tmp_set;
tmp_set = tmp_set->next) {
if ((tmp_set->desc)
&& (strncmp(tmp_set->desc, "GPT Safety",
......@@ -118,25 +121,26 @@ tsk_vs_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset,
if (tsk_verbose)
tsk_fprintf(stderr,
"mm_open: Ignoring DOS Safety GPT Partition\n");
set = NULL;
vs_set = NULL;
prev_type = NULL;
prev_vs = NULL;
break;
}
}
}
if (set != NULL) {
vs_set->close(vs_set);
/* If we never found the safety, then we have a conflict. */
if (prev_type != NULL) {
prev_vs->close(prev_vs);
vs->close(vs);
tsk_error_reset();
tsk_error_set_errno(TSK_ERR_VS_MULTTYPE);
tsk_error_set_errstr("GPT or %s at %" PRIuDADDR, set,
tsk_error_set_errstr("GPT or %s at %" PRIuDADDR, prev_type,
offset);
return NULL;
}
}
set = "GPT";
vs_set = vs;
prev_type = "GPT";
prev_vs = vs;
}
}
else {
......@@ -144,16 +148,16 @@ tsk_vs_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset,
}
if ((vs = tsk_vs_sun_open(img_info, offset)) != NULL) {
if (set == NULL) {
set = "Sun";
vs_set = vs;
if (prev_type == NULL) {
prev_type = "Sun";
prev_vs = vs;
}
else {
vs_set->close(vs_set);
prev_vs->close(prev_vs);
vs->close(vs);
tsk_error_reset();
tsk_error_set_errno(TSK_ERR_VS_MULTTYPE);
tsk_error_set_errstr("Sun or %s at %" PRIuDADDR, set,
tsk_error_set_errstr("Sun or %s at %" PRIuDADDR, prev_type,
offset);
return NULL;
}
......@@ -163,16 +167,16 @@ tsk_vs_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset,
}
if ((vs = tsk_vs_mac_open(img_info, offset)) != NULL) {
if (set == NULL) {
set = "Mac";
vs_set = vs;
if (prev_type == NULL) {
prev_type = "Mac";
prev_vs = vs;
}
else {
vs_set->close(vs_set);
prev_vs->close(prev_vs);
vs->close(vs);
tsk_error_reset();
tsk_error_set_errno(TSK_ERR_VS_MULTTYPE);
tsk_error_set_errstr("Mac or %s at %" PRIuDADDR, set,
tsk_error_set_errstr("Mac or %s at %" PRIuDADDR, prev_type,
offset);
return NULL;
}
......@@ -181,7 +185,7 @@ tsk_vs_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset,
tsk_error_reset();
}
if (vs_set == NULL) {
if (prev_vs == NULL) {
tsk_error_reset();
// Check whether the volume system appears to be encrypted.
......@@ -202,8 +206,10 @@ tsk_vs_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset,
return NULL;
}
return vs_set;
return prev_vs;
}
// Not autodetect
else {
switch (type) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment