]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r298671,r298672:
authorngie <ngie@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 13 May 2016 08:54:08 +0000 (08:54 +0000)
committerngie <ngie@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 13 May 2016 08:54:08 +0000 (08:54 +0000)
commit375eedc71f7eb42252edd96c53c4ab336b40ed32
treec1ff700a0dfd58752dc18f83183cddcb1a0b7c4d
parent46ae92e128cc6f4c7cfcd150867d056f101f678a
MFC r298671,r298672:

r298671 (by cem):

g_part_bsd64: Check for valid on-disk npartitions value

This value is u32 on disk, but assigned to an int in memory.  After we do the
implicit conversion via assignment, check that the result is at least one[1]
(non-negative[2]).

1. The subsequent for-loop iterates from gpt_entries minus one, down, until
   reaching zero.  A negative or zero initial index results in undefined signed
   integer overflow.
2. It is also used to index into arrays later.

In practice, we expected non-malicious disks to contain small positive values.

CID: 1223202

r298672 (by cem):

g_part_bsd64: Delete duplicate/dead code

RAW_PART is handled earlier in the loop.

CID: 1223201

git-svn-id: svn://svn.freebsd.org/base/stable/10@299629 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/geom/part/g_part_bsd64.c