]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r298671,r298672:
authorngie <ngie@FreeBSD.org>
Fri, 13 May 2016 08:54:08 +0000 (08:54 +0000)
committerngie <ngie@FreeBSD.org>
Fri, 13 May 2016 08:54:08 +0000 (08:54 +0000)
commitb8862d73f093e6f41ef3b125aeffec576f42a924
treec1ff700a0dfd58752dc18f83183cddcb1a0b7c4d
parent96ce93c4effd8c3892503e3afbfe6f1b7b694cdf
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
sys/geom/part/g_part_bsd64.c