From 2d355ebb7392de6f6e3a9011bb8a921a3ccf63a8 Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Wed, 29 Apr 2015 12:33:10 -0700 Subject: [PATCH] Fixed a bug in Drawing::SetMessage - The terminating null character of the message string is now written. - Along with baef257, this fully resolves #60. --- xpcPlugin/Drawing.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xpcPlugin/Drawing.cpp b/xpcPlugin/Drawing.cpp index e7245ad..63caf55 100644 --- a/xpcPlugin/Drawing.cpp +++ b/xpcPlugin/Drawing.cpp @@ -192,7 +192,7 @@ namespace XPC { //Determine size of message and clear instead if the message string //is empty. - size_t len = strnlen(msg, MSG_MAX); + size_t len = strnlen(msg, MSG_MAX - 1); if (len == 0) { ClearMessage(); @@ -200,7 +200,7 @@ namespace XPC } //Set the message, location, and mark new lines. - strncpy(msgVal, msg, len); + strncpy(msgVal, msg, len + 1); newLineCount = 0; for (size_t i = 0; i < len && newLineCount < MSG_LINE_MAX; ++i) {