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:
ae 2011-01-27 08:02:26 +00:00
parent 46a820cb0e
commit 258630083a

View File

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