Skip to content

Commit 3700801

Browse files
committed
Fixed issue with strncpy
1 parent 06ec575 commit 3700801

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/CheerLights.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
#define BUFFER_SIZE 128
66

77
CheerLights::CheerLights() {
8-
strcpy(_colorName, "black");
9-
_colorHex = 0x000000;
8+
strncpy(_colorName, "black", sizeof(_colorName) - 1);
9+
_colorName[sizeof(_colorName) - 1] = '\0';
10+
_colorHex = 0x000000;
1011
}
1112

1213
void CheerLights::begin(const char* ssid, const char* password) {

src/CheerLights.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CheerLights {
4141
void _fetchColor();
4242
const char* _ssid;
4343
const char* _password;
44-
const char* _colorName;
44+
char _colorName[32];
4545
uint32_t _colorHex;
4646
};
4747

0 commit comments

Comments
 (0)