diff --git a/SUBinaryDeltaCommon.m b/SUBinaryDeltaCommon.m index 7f592996..1caf7019 100644 --- a/SUBinaryDeltaCommon.m +++ b/SUBinaryDeltaCommon.m @@ -47,8 +47,10 @@ NSString *temporaryFilename(NSString *base) { NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]]; const char *fsrepr = [template fileSystemRepresentation]; - char *buffer = (char *)malloc(strlen(fsrepr) + 1); - strcpy(buffer, fsrepr); + + const size_t buffer_len = strlen(fsrepr) + 1; + char *buffer = (char *)malloc(buffer_len); + strlcpy(buffer, fsrepr, buffer_len); // mkstemp() can't be used, beause it returns a file descriptor, and XAR API requires a filename NSString *ret = stringWithFileSystemRepresentation(mktemp(buffer));