arduino / ArduinoCore-avr

The Official Arduino AVR core
https://www.arduino.cc
1.25k stars 1.06k forks source link

Fix for String memory corruption #416

Closed drmpf closed 3 years ago

drmpf commented 3 years ago

This patch fixes String memory corruption due to str +=str; and String(1.0,40); // and similar were result exceeds the local buf[33]

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

matthijskooijman commented 3 years ago

Thanks for your contribution, sounds like useful things to fix indeed.

However, the development of the String class currently happens at https://github.com/arduino/ArduinoCore-API. The AVR core does note make use of the repository yet, but it should do so in the future, so any changes to the String class should be made there. Maybe you could check if this issue exists in that repo and maybe submit a fix there if it does?

As for the actual changes, some remarks:

drmpf commented 3 years ago

Thanks for the pointer to the ArduinoCore-API. You are correct about the strcpy, bad merge on my part should have been commented out. Yes the fix you noted removes the need for my memmove The float/double to string conversion has a fix committed there also. So my change also may not needed except perhaps the nan/inf handling.