diff options
author | rnoland <rnoland@FreeBSD.org> | 2009-11-12 16:28:39 +0000 |
---|---|---|
committer | rnoland <rnoland@FreeBSD.org> | 2009-11-12 16:28:39 +0000 |
commit | ab54ccdf3ee1752793bb4b58c787a65df7527204 (patch) | |
tree | a0824f7e0000690c0462937401550d49f3094891 /sys/geom/part/g_part_gpt.c | |
parent | 00d48829b61e72f5c5d464333400559ec6056614 (diff) | |
download | FreeBSD-src-ab54ccdf3ee1752793bb4b58c787a65df7527204.zip FreeBSD-src-ab54ccdf3ee1752793bb4b58c787a65df7527204.tar.gz |
We need to allocate space for the header in the create path also.
This fixes a null pointer dereference with "gpart create -s GPT" after
the previous commit.
Reported by: Yuri Pankov
Pointyhat to: me
MFC after: 1 week
Diffstat (limited to 'sys/geom/part/g_part_gpt.c')
-rw-r--r-- | sys/geom/part/g_part_gpt.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c index aabbec1..a153274 100644 --- a/sys/geom/part/g_part_gpt.c +++ b/sys/geom/part/g_part_gpt.c @@ -444,6 +444,9 @@ g_part_gpt_create(struct g_part_table *basetable, struct g_part_parms *gpp) table->lba[GPT_ELT_SECHDR] = last; table->lba[GPT_ELT_SECTBL] = last - tblsz; + /* Allocate space for the header */ + table->hdr = g_malloc(sizeof(struct gpt_hdr), M_WAITOK | M_ZERO); + bcopy(GPT_HDR_SIG, table->hdr->hdr_sig, sizeof(table->hdr->hdr_sig)); table->hdr->hdr_revision = GPT_HDR_REVISION; table->hdr->hdr_size = offsetof(struct gpt_hdr, padding); |