This repository was archived by the owner on Mar 17, 2025. It is now read-only.
This repository was archived by the owner on Mar 17, 2025. It is now read-only.
Taking substring of readStringUntil without handling timeout, or checking result. #120
Open
Description
In FirebaseArduino::readEvent() the following code is a bug:
String type = client->readStringUntil('\n').substring(7);
readStringUntil will read until a '\n' OR until it times out, default is one second. This makes substring(7) dangerous. The result of getting a substring out of bounds of the string is undefined (according to: https://www.arduino.cc/en/Tutorial/StringSubstring, which says "Caution: make sure your index values are within the String's length or you'll get unpredictable results.")
At the least we should check the length of the returned string before getting the substring.