Date: Thu, 12 Nov 2009 16:28:39 +0000 (UTC) From: Robert Noland <rnoland@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r199228 - head/sys/geom/part Message-ID: <200911121628.nACGSdlv035921@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rnoland Date: Thu Nov 12 16:28:39 2009 New Revision: 199228 URL: http://svn.freebsd.org/changeset/base/199228 Log: 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 Modified: head/sys/geom/part/g_part_gpt.c Modified: head/sys/geom/part/g_part_gpt.c ============================================================================== --- head/sys/geom/part/g_part_gpt.c Thu Nov 12 15:59:05 2009 (r199227) +++ head/sys/geom/part/g_part_gpt.c Thu Nov 12 16:28:39 2009 (r199228) @@ -444,6 +444,9 @@ g_part_gpt_create(struct g_part_table *b 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911121628.nACGSdlv035921>