Menu

#103 Division by 0 in flash/nor/nrf51.c

0.9.0
new
nobody
None
2015-08-05
2015-07-30
No

Hi,

It's possible to get division by 0 and crash the application in flash/nor/nrf51.c.

On line 630 you read:
res = target_read_u32(chip->target, NRF51_FICR_CODEPAGESIZE, &chip->code_page_size);

And then on line 650 you divide:
bank->num_sectors = bank->size / chip->code_page_size;

It's possible for chip->code_page_size to be 0 and crash the application.

It happened to me.

--
Best regards,
Andrzej Telszewski

Discussion

  • Angus Gratton

    Angus Gratton - 2015-08-05

    Hi Andrzej,

    Thanks for reporting this. It should be easy to fix, I just wanted to check - a code page size of zero is because of a bad SWD connection, yes? It's still a fatal error, but openocd should just print an error and fail cleanly instead of crashing?

    Thanks,

    Angus

     
    • Andrzej Telszewski

      Hi,

      I'm sorry for inconvenience, but SF ticket system just made me want to jump off of a window. I'm quite young, but I'm longing to the days of plain text systems. I'm going to write on mailing list.

      --
      Best regards,
      Andrzej Telszewski

       

      Last edit: Andrzej Telszewski 2015-09-15

Log in to post a comment.