From ca1a5ea845c283a9c84fd2ae9f6d152cca354183 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 22 Dec 2013 18:00:45 +1100 Subject: Avoid unsafe strcpy, strncpy, and strcat replacing with safer functions which guaranty termination where possible. --- cocoa/PlatCocoa.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'cocoa') diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 3d3417b82..5567088d1 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1839,8 +1839,7 @@ void ListBoxImpl::GetValue(int n, char* value, int len) value[0] = '\0'; return; } - strncpy(value, textString, len); - value[len - 1] = '\0'; + strlcpy(value, textString, len); } void ListBoxImpl::RegisterImage(int type, const char* xpm_data) @@ -2217,8 +2216,7 @@ bool Platform::ShowAssertionPopUps(bool assertionPopUps_) void Platform::Assert(const char *c, const char *file, int line) { char buffer[2000]; - sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line); - strcat(buffer, "\r\n"); + snprintf(buffer, sizeof(buffer), "Assertion [%s] failed at %s %d\r\n", c, file, line); Platform::DebugDisplay(buffer); #ifdef DEBUG // Jump into debugger in assert on Mac (CL269835) -- cgit v1.2.3