Skip to content

Commit 491a217

Browse files
authored
Merge pull request #3112 from compnerd/overflow-5.5
[5.5] CoreFoundation: ensure that we do not overflow the dest
2 parents c8c2525 + 170c1fb commit 491a217

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CoreFoundation/Base.subproj/CFPlatform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ CF_CROSS_PLATFORM_EXPORT int _CFThreadGetName(char *buf, int length) {
16111611
char *buffer = calloc(szLength + 1, sizeof(char));
16121612
WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, pszThreadDescription,
16131613
-1, buffer, szLength, NULL, NULL);
1614-
memcpy(buf, buffer, length - 1);
1614+
memcpy(buf, buffer, MIN(szLength, length - 1));
16151615
buf[MIN(szLength, length - 1)] = '\0';
16161616
free(buffer);
16171617
}

0 commit comments

Comments
 (0)