Skip to content

Commit

Permalink
part: check each variable for capability calculation
Browse files Browse the repository at this point in the history
In order to calculate the capability, we use the below expression to check:
((dev_desc->lba * dev_desc->blksz)>0L)
If the capability is greater than 4GB (e.g. 8GB = 8 * 1024 * 104 * 1024),
the result will overflow, the low 32bit may be zero.

Therefore, change to check each variable to fix this potential issue.

Signed-off-by: Jerry Huang <[email protected]>
  • Loading branch information
Jerry Huang authored and trini committed Dec 6, 2012
1 parent e3ff797 commit 33699df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion disk/part.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void dev_print (block_dev_desc_t *dev_desc)
break;
}
puts ("\n");
if ((dev_desc->lba * dev_desc->blksz)>0L) {
if (dev_desc->lba > 0L && dev_desc->blksz > 0L) {
ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem;
lbaint_t lba;

Expand Down

0 comments on commit 33699df

Please sign in to comment.