Skip to content

Commit 7e59601

Browse files
committed
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.
1 parent 221bb41 commit 7e59601

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Adafruit_GFX.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,7 @@ void Adafruit_GFX_Button::initButtonUL(Adafruit_GFX *gfx, int16_t x1,
16611661
_textsize_y = textsize_y;
16621662
_gfx = gfx;
16631663
strncpy(_label, label, 9);
1664+
_label[9] = 0; // strncpy does not place a null at the end. When 'label' is 9 characters, _label is not terminated.
16641665
}
16651666

16661667
/**************************************************************************/

0 commit comments

Comments
 (0)