From 43a8a0f433e3f1971cf1af62b0386fd7c3c786e6 Mon Sep 17 00:00:00 2001 From: Amulya Kumar Sahoo Date: Fri, 30 May 2014 11:44:50 +0530 Subject: Fix of a bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stream::find(char *target) passes NULL as “terminator” to Stream::findUntil(char *target, char *terminator), which immediately dereferences it by passing it on to strlen(): bool Stream::find(char *target) { return findUntil(target, NULL); } // as find but search ends if the terminator string is found bool Stream::findUntil(char *target, char *terminator) { return findUntil(target, strlen(target), terminator, strlen(terminator)); } --- cores/arduino/Stream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/Stream.cpp b/cores/arduino/Stream.cpp index aafb7fc..f21a411 100644 --- a/cores/arduino/Stream.cpp +++ b/cores/arduino/Stream.cpp @@ -75,7 +75,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi // find returns true if the target string is found bool Stream::find(char *target) { - return findUntil(target, NULL); + return findUntil(target, ""); } // reads data from the stream until the target string of given length is found -- cgit v1.2.3-18-g5258 From 2f98fe16d79170f6962f681295636a5c4fe010d4 Mon Sep 17 00:00:00 2001 From: Amulya Kumar Sahoo Date: Fri, 30 May 2014 11:47:08 +0530 Subject: Fix of a bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stream::find(char *target) passes NULL as “terminator” to Stream::findUntil(char *target, char *terminator), which immediately dereferences it by passing it on to strlen() : bool Stream::find(char *target) { return findUntil(target, NULL); } // as find but search ends if the terminator string is found bool Stream::findUntil(char *target, char *terminator) { return findUntil(target, strlen(target), terminator, strlen(terminator)); } --- cores/robot/Stream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/robot/Stream.cpp b/cores/robot/Stream.cpp index aafb7fc..f21a411 100644 --- a/cores/robot/Stream.cpp +++ b/cores/robot/Stream.cpp @@ -75,7 +75,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi // find returns true if the target string is found bool Stream::find(char *target) { - return findUntil(target, NULL); + return findUntil(target, ""); } // reads data from the stream until the target string of given length is found -- cgit v1.2.3-18-g5258 From 12219b37d5f4569649cd4dac247fbfcee5dfb79b Mon Sep 17 00:00:00 2001 From: Embedded Micro Date: Tue, 10 Jun 2014 08:48:23 -0700 Subject: Update USBAPI.h Fixes bug where Serial.read() would always return 0 as the first byte. --- cores/arduino/USBAPI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h index d506b58..753bc6b 100644 --- a/cores/arduino/USBAPI.h +++ b/cores/arduino/USBAPI.h @@ -28,7 +28,7 @@ extern USBDevice_ USBDevice; class Serial_ : public Stream { private: - int peek_buffer; + int peek_buffer = -1; public: void begin(unsigned long); void begin(unsigned long, uint8_t); -- cgit v1.2.3-18-g5258