Skip to content

Commit

Permalink
Added bounds checking on pinMode
Browse files Browse the repository at this point in the history
  • Loading branch information
BarryPSmith committed Nov 30, 2019
1 parent c8d6aef commit 3122511
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

void pinMode(uint8_t pin, uint8_t mode)
{
//prevent reading beyond end of arrays:
if (pin > sizeof(digital_pin_to_port_PGM) / sizeof(digital_pin_to_port_PGM[0])) return;

uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *reg, *out;
Expand Down

0 comments on commit 3122511

Please sign in to comment.