Skip to content

Commit

Permalink
Fix a panic caused by a corrupted table when the header is
Browse files Browse the repository at this point in the history
still valid. We were checking the state of the header and
not the table.

PR:		119868
Based on a patch from:	Jaakko Heinonen <jh@saunalahti.fi>
MFC after: 1 week
  • Loading branch information
marcel authored and marcel committed Nov 6, 2008
1 parent 1d778dd commit 5ebda14
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sys/geom/part/g_part_gpt.c
Expand Up @@ -625,13 +625,16 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp)
if (table->state[GPT_ELT_PRIHDR] == GPT_STATE_OK &&
table->state[GPT_ELT_SECHDR] == GPT_STATE_OK &&
!gpt_matched_hdrs(&prihdr, &sechdr)) {
if (table->state[GPT_ELT_PRITBL] == GPT_STATE_OK)
if (table->state[GPT_ELT_PRITBL] == GPT_STATE_OK) {
table->state[GPT_ELT_SECHDR] = GPT_STATE_INVALID;
else
table->state[GPT_ELT_SECTBL] = GPT_STATE_MISSING;
} else {
table->state[GPT_ELT_PRIHDR] = GPT_STATE_INVALID;
table->state[GPT_ELT_PRITBL] = GPT_STATE_MISSING;
}
}

if (table->state[GPT_ELT_PRIHDR] != GPT_STATE_OK) {
if (table->state[GPT_ELT_PRITBL] != GPT_STATE_OK) {
printf("GEOM: %s: the primary GPT table is corrupt or "
"invalid.\n", pp->name);
printf("GEOM: %s: using the secondary instead -- recovery "
Expand All @@ -641,7 +644,7 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp)
if (pritbl != NULL)
g_free(pritbl);
} else {
if (table->state[GPT_ELT_SECHDR] != GPT_STATE_OK) {
if (table->state[GPT_ELT_SECTBL] != GPT_STATE_OK) {
printf("GEOM: %s: the secondary GPT table is corrupt "
"or invalid.\n", pp->name);
printf("GEOM: %s: using the primary only -- recovery "
Expand Down

0 comments on commit 5ebda14

Please sign in to comment.