While inspecting the disklabel check that start offset of partition is

within provider's bounds. If not then reject this disklabel.
Mark bbarea as NULL to do not free it again in destroy method.

MFC after:	1 week
This commit is contained in:
Andrey V. Elsukov 2011-01-27 08:02:26 +00:00
parent 51fcc8350c
commit 1313160649

View File

@ -426,6 +426,8 @@ g_part_bsd_read(struct g_part_table *basetable, struct g_consumer *cp)
continue; continue;
if (part.p_offset < table->offset) if (part.p_offset < table->offset)
continue; continue;
if (part.p_offset - table->offset > basetable->gpt_last)
goto invalid_label;
baseentry = g_part_new_entry(basetable, index + 1, baseentry = g_part_new_entry(basetable, index + 1,
part.p_offset - table->offset, part.p_offset - table->offset,
part.p_offset - table->offset + part.p_size - 1); part.p_offset - table->offset + part.p_size - 1);
@ -440,6 +442,7 @@ g_part_bsd_read(struct g_part_table *basetable, struct g_consumer *cp)
invalid_label: invalid_label:
printf("GEOM: %s: invalid disklabel.\n", pp->name); printf("GEOM: %s: invalid disklabel.\n", pp->name);
g_free(table->bbarea); g_free(table->bbarea);
table->bbarea = NULL;
return (EINVAL); return (EINVAL);
} }