Skip to content

Commit

Permalink
examples/arduino_hello-world: fix buffer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mguetschow committed Nov 25, 2024
1 parent 9edbe15 commit 18c6991
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/arduino_hello-world/hello-world.sketch
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// Assign the default LED pin
int ledPin = ARDUINO_LED;

#define BUF_LEN 64
// input buffer for receiving chars on the serial port
int buf[64];
int buf[BUF_LEN];

// counter that counts the number of received chars
int count = 0;
Expand Down Expand Up @@ -64,7 +65,7 @@ void loop(void)
count = 0;
}
// else we just remember the incoming char
else {
else if (count < BUF_LEN) {
buf[count++] = tmp;
}
}
Expand Down

0 comments on commit 18c6991

Please sign in to comment.