From 18c6991d4a17fa4740c0e9fba4b07306e8a8d53e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikolai=20G=C3=BCtschow?= Date: Mon, 25 Nov 2024 16:16:48 +0100 Subject: [PATCH] examples/arduino_hello-world: fix buffer overflow --- examples/arduino_hello-world/hello-world.sketch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/arduino_hello-world/hello-world.sketch b/examples/arduino_hello-world/hello-world.sketch index bdf414c0fd..436a96d097 100644 --- a/examples/arduino_hello-world/hello-world.sketch +++ b/examples/arduino_hello-world/hello-world.sketch @@ -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; @@ -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; } }