From 57811addab5ebd9379af448ba8931fdfe79d6dfb Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Fri, 31 Jul 2020 18:24:17 +0200 Subject: [PATCH] Avoid buffer overflow on invalid DateTime The timestamp() method would overflow its internal buffer if any of the data fields of the provided DateTime (save for yOff) was larger than 99. Even though any such DateTime would be invalid, it should not corrupt the memory. --- RTClib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RTClib.cpp b/RTClib.cpp index b7562b04..4d00eb81 100644 --- a/RTClib.cpp +++ b/RTClib.cpp @@ -695,7 +695,7 @@ bool DateTime::operator==(const DateTime &right) const { */ /**************************************************************************/ String DateTime::timestamp(timestampOpt opt) { - char buffer[20]; + char buffer[25]; // large enough for any DateTime, including invalid ones // Generate timestamp according to opt switch (opt) {