Skip to content

Commit b097d68

Browse files
committed
Added 0 length verification for read and write command handlers
1 parent b03376d commit b097d68

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

firmware/nand_programmer.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ static int np_cmd_nand_write_start(np_prog_t *prog)
385385
return NP_ERR_ADDR_NOT_ALIGN;
386386
}
387387

388+
if (!len)
389+
{
390+
ERROR_PRINT("Length is 0\r\n");
391+
return NP_ERR_LEN_INVALID;
392+
}
393+
388394
if (len & (prog->chip_info->page_size - 1))
389395
{
390396
ERROR_PRINT("Length 0x%lx is not aligned to page size 0x%lx\r\n",
@@ -621,6 +627,12 @@ static int _np_cmd_nand_read(np_prog_t *prog)
621627
return NP_ERR_ADDR_NOT_ALIGN;
622628
}
623629

630+
if (!len)
631+
{
632+
ERROR_PRINT("Length is 0\r\n");
633+
return NP_ERR_LEN_INVALID;
634+
}
635+
624636
if (len & (prog->chip_info->page_size - 1))
625637
{
626638
ERROR_PRINT("Read length 0x%lx is not aligned to page size 0x%lx\r\n",

0 commit comments

Comments
 (0)