Skip to content

Commit

Permalink
Fix of a bug
Browse files Browse the repository at this point in the history
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));
}
  • Loading branch information
amulya349 committed May 30, 2014
1 parent 44b5096 commit 91f0dbc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hardware/arduino/cores/arduino/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 91f0dbc

Please sign in to comment.