Skip to content

Commit 99b54ac

Browse files
committed
fix(mdns): Fix name mangling not to use strcpy()
Since it was flagged by clang-tidy as insecture API
1 parent f5be2f4 commit 99b54ac

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

components/mdns/mdns.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,13 @@ static char *_mdns_mangle_name(char *in)
253253
}
254254
sprintf(ret, "%s-2", in);
255255
} else {
256-
ret = malloc(strlen(in) + 2); //one extra byte in case 9-10 or 99-100 etc
256+
size_t in_len = strlen(in);
257+
ret = malloc(in_len + 2); //one extra byte in case 9-10 or 99-100 etc
257258
if (ret == NULL) {
258259
HOOK_MALLOC_FAILED;
259260
return NULL;
260261
}
261-
strcpy(ret, in);
262+
memcpy(ret, in, in_len);
262263
int baseLen = p - in; //length of 'bla' in 'bla-123'
263264
//overwrite suffix with new suffix
264265
sprintf(ret + baseLen, "-%d", suffix + 1);

0 commit comments

Comments
 (0)