diff --git a/tsk/vs/dos.c b/tsk/vs/dos.c index 06e95027b08fca922967b3f86e297d9c3282eca4..f4a07b745632c2e6b0b56e73c23a1d1fc7af50ad 100644 --- a/tsk/vs/dos.c +++ b/tsk/vs/dos.c @@ -751,6 +751,25 @@ dos_load_ext_table(TSK_VS_INFO * vs, TSK_DADDR_T sect_cur, * in extended partitions */ if (dos_is_ext(part->ptype)) { + TSK_VS_PART_INFO *part_info; + + /* Sanity check to prevent infinite recursion in dos_load_ext_table. + * If we already have a partition with this starting address then + * return an error. This will prevent any more partitions from being + * added but will leave any existing partitions alone. */ + part_info = vs->part_list; + while (part_info != NULL) { + if (part_info->start == (TSK_DADDR_T)(sect_ext_base + part_start)) { + if (tsk_verbose) + tsk_fprintf(stderr, + "Starting sector %" PRIuDADDR + " of extended partition has already been used\n", + (TSK_DADDR_T)(sect_ext_base + part_start)); + return 1; + } + part_info = part_info->next; + } + /* part start is added to the start of the * first extended partition (the primary * extended partition) */