From 70046f6e070f1dfff0288ed4aa8fd28ab0ba2dfe Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Sun, 29 Jun 2014 01:19:03 -0400 Subject: [PATCH] Quiet Clang static analyzer. --- SUBinaryDeltaCommon.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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));