1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-08 11:31:44 +00:00

bdk: nx emmc bis: fix out of cluster bounds accesses

This commit is contained in:
CTCaer 2022-01-29 01:40:38 +02:00
parent 6666dd4b46
commit 52bb6a96e5

View file

@ -251,7 +251,12 @@ int nx_emmc_bis_read(u32 sector, u32 count, void *buff)
while (count) while (count)
{ {
u32 sct_cnt = MIN(count, BIS_CLUSTER_SECTORS); // Get sector index in cluster and use it as boundary check.
u32 cnt_max = (curr_sct % BIS_CLUSTER_SECTORS);
cnt_max = BIS_CLUSTER_SECTORS - cnt_max;
u32 sct_cnt = MIN(count, cnt_max); // Only allow cluster sized access.
if (nx_emmc_bis_read_block(curr_sct, sct_cnt, buf)) if (nx_emmc_bis_read_block(curr_sct, sct_cnt, buf))
return 0; return 0;
@ -270,7 +275,12 @@ int nx_emmc_bis_write(u32 sector, u32 count, void *buff)
while (count) while (count)
{ {
u32 sct_cnt = MIN(count, BIS_CLUSTER_SECTORS); // Get sector index in cluster and use it as boundary check.
u32 cnt_max = (curr_sct % BIS_CLUSTER_SECTORS);
cnt_max = BIS_CLUSTER_SECTORS - cnt_max;
u32 sct_cnt = MIN(count, cnt_max); // Only allow cluster sized access.
if (nx_emmc_bis_write_block(curr_sct, sct_cnt, buf, false)) if (nx_emmc_bis_write_block(curr_sct, sct_cnt, buf, false))
return 0; return 0;