Project

General

Profile

Actions

Bug #3015

closed

sbin/gpt/show.c:133: do we always find what we are looking for ?

Added by dcb almost 7 years ago. Updated almost 5 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
04/11/2017
Due date:
% Done:

0%

Estimated time:

Description

dragonfly/sbin/gpt/show.c:133]: (error) Array 'mbr.mbr_part4' accessed at index 4, which is out of bounds.

Source code is

for (i = 0; i < 4; i++) {
start = le16toh(mbr->mbr_part[i].part_start_hi);
start = (start << 16) +
le16toh(mbr->mbr_part[i].part_start_lo);
if (m->map_start == p->map_start + start)
break;
}
printf("%d", mbr->mbr_part[i].part_typ);

In the final printf, the code assumes we have found what we are looking for.

Maybe the code would be stronger if it dealt with the case where it didn't.

Actions

Also available in: Atom PDF