Skip to content

Commit eb619d9

Browse files
committed
Fix x10 id size warnings and truncate to 5 chars
1 parent 2ef4f9c commit eb619d9

File tree

1 file changed

+4
-4
lines changed
  • libs/pilight/libs/pilight/protocols/433.92

1 file changed

+4
-4
lines changed

libs/pilight/libs/pilight/protocols/433.92/x10.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void parseCode(void) {
7575
}
7676
}
7777

78-
char id[4]= {'\0'};
78+
char id[6]= {'\0'};
7979
int l = letters[binToDecRev(binary, 0, 3)];
8080
int s = binary[18];
8181
int i = 1;
@@ -89,7 +89,7 @@ static void parseCode(void) {
8989
}
9090
i += binToDec(binary, 19, 20);
9191
if(c1 == 255 && c2 == 255) {
92-
snprintf(id, sizeof(id), "%c%d", l, i);
92+
snprintf(id, sizeof(id)-1, "%c%d", (char)l, (unsigned char)i);
9393
createMessage(id, s);
9494
}
9595
}
@@ -175,15 +175,15 @@ static void createFooter(void) {
175175
}
176176

177177
static int createCode(struct JsonNode *code) {
178-
char id[4] = {'\0'};
178+
char id[6] = {'\0'};
179179
int state = -1;
180180
double itmp = -1;
181181
char *stmp = NULL;
182182

183183
strcpy(id, "-1");
184184

185185
if(json_find_string(code, "id", &stmp) == 0)
186-
strncpy(id, stmp, sizeof(id));
186+
strncpy(id, stmp, sizeof(id)-1);
187187
if(json_find_number(code, "off", &itmp) == 0)
188188
state=1;
189189
else if(json_find_number(code, "on", &itmp) == 0)

0 commit comments

Comments
 (0)