From 092e58cff1df415b3c296a78c9cfcafe61d39307 Mon Sep 17 00:00:00 2001 From: Robert Wolff Date: Mon, 3 May 2021 22:31:05 -0700 Subject: [PATCH] Dangerous edge case for non-null-terminated string strncpy() does not place a null terminator when the max characters is reached of '9' in this case. So, any buttons with 9 or more in the source will wind up with a potentially non-null-terminated _label. --- Extensions/Button.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Extensions/Button.cpp b/Extensions/Button.cpp index 9467d63..b1d9ad4 100644 --- a/Extensions/Button.cpp +++ b/Extensions/Button.cpp @@ -36,6 +36,7 @@ void TFT_eSPI_Button::initButtonUL( _textsize = textsize; _gfx = gfx; strncpy(_label, label, 9); + _label[9] = 0; // strncpy does not place a null at the end. When 'label' is 9 characters, _label is not terminated. } // Adjust text datum and x, y deltas