Skip to content

Commit a55ebe6

Browse files
committed
Add check buffer overflow.
Change-Id: I4ebf907457133097c21d655b79e357a614eafb0e
1 parent 9a8450d commit a55ebe6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

firmware/programmer/nand_programmer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,13 @@ static int np_cmd_nand_write_start(np_prog_t *prog)
648648
return ret;
649649
}
650650

651+
if (prog->page_size > sizeof(prog->page.buf))
652+
{
653+
ERROR_PRINT("Page size 0x%lx"
654+
" is more then buffer size 0x%x\r\n", prog->page_size, sizeof(prog->page.buf));
655+
return NP_ERR_BUF_OVERFLOW;
656+
}
657+
651658
prog->addr = addr;
652659
prog->len = len;
653660
prog->addr_is_set = 1;

0 commit comments

Comments
 (0)