Page MenuHomeFreeBSD

D36717.id111080.diff
No OneTemporary

D36717.id111080.diff

diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c
--- a/sys/geom/part/g_part_gpt.c
+++ b/sys/geom/part/g_part_gpt.c
@@ -85,6 +85,7 @@
GPT_STATE_MISSING, /* No signature found. */
GPT_STATE_CORRUPT, /* Checksum mismatch. */
GPT_STATE_INVALID, /* Nonconformant/invalid. */
+ GPT_STATE_UNSUPPORTED, /* Not supported. */
GPT_STATE_OK /* Perfectly fine. */
};
@@ -148,6 +149,8 @@
{ 0, 0 }
};
+#define MAXENTSIZE 1024
+
static struct g_part_scheme g_part_gpt_scheme = {
"GPT",
g_part_gpt_methods,
@@ -518,7 +521,11 @@
if (lba >= hdr->hdr_lba_start && lba <= hdr->hdr_lba_end)
goto fail;
- table->state[elt] = GPT_STATE_OK;
+ if (hdr->hdr_entries > g_part_gpt_scheme.gps_maxent ||
+ hdr->hdr_entsz > MAXENTSIZE)
+ table->state[elt] = GPT_STATE_UNSUPPORTED;
+ else
+ table->state[elt] = GPT_STATE_OK;
le_uuid_dec(&buf->hdr_uuid, &hdr->hdr_uuid);
hdr->hdr_crc_table = le32toh(buf->hdr_crc_table);
@@ -961,10 +968,19 @@
/* Fail if we haven't got any good tables at all. */
if (table->state[GPT_ELT_PRITBL] != GPT_STATE_OK &&
table->state[GPT_ELT_SECTBL] != GPT_STATE_OK) {
- printf("GEOM: %s: corrupt or invalid GPT detected.\n",
- pp->name);
- printf("GEOM: %s: GPT rejected -- may not be recoverable.\n",
- pp->name);
+ /* XXX arbitrarily report unsupported as the table is not checked */
+ if (table->state[GPT_ELT_PRIHDR] == GPT_STATE_UNSUPPORTED &&
+ table->state[GPT_ELT_SECHDR] == GPT_STATE_UNSUPPORTED &&
+ gpt_matched_hdrs(prihdr, sechdr)) {
+ printf("GEOM: %s: unsupported GPT detected.\n",
+ pp->name);
+ printf("GEOM: %s: GPT rejected.\n", pp->name);
+ } else {
+ printf("GEOM: %s: corrupt or invalid GPT detected.\n",
+ pp->name);
+ printf("GEOM: %s: GPT rejected -- may not be recoverable.\n",
+ pp->name);
+ }
if (prihdr != NULL)
g_free(prihdr);
if (pritbl != NULL)

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 23, 10:59 PM (11 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27890864
Default Alt Text
D36717.id111080.diff (1 KB)

Event Timeline