OpenSprinkler / OpenSprinkler-Firmware

OpenSprinkler Unified Firmware for OpenSprinkler, OpenSprinkler Pi, and OpenSprinkler Beagle.
http://www.opensprinkler.com
GNU General Public License v3.0
474 stars 286 forks source link

Fix use-after-free when using custom ntp server #287

Closed os04 closed 3 months ago

os04 commented 3 months ago

This also fixes issue #264

Tested on my OpenSprinkler 3

Issue:

OpenSprinkler likes to periodically lookup gibberish DNS names when a custom NTP server has been configured. This lookup is often correlated with lookups of time.google.com and time.nist.gov, and the configured NTP server stops being queried when this starts to happen. Exact issue presentation can vary based on how some of the other settings are configured.

Cause:

It seems that configTime() requires its strings to be accessible after the function call is finished.

Fix:

Allocate a static buffer for the NTP server IP address string.

arfrie22 commented 3 months ago

Thank you for catching this.