]> granicus.if.org Git - libjpeg-turbo/commitdiff
tjbench.c: Fix compiler warnings with GCC 8
authorDRC <information@libjpeg-turbo.org>
Mon, 12 Nov 2018 18:27:23 +0000 (12:27 -0600)
committerDRC <information@libjpeg-turbo.org>
Mon, 12 Nov 2018 18:27:23 +0000 (12:27 -0600)
strncpy() may fail to truncate dst if len == strlen(dst).

tjbench.c

index 9ab0ea2ac920d1aa2db18f60e74c4236fc3737ef..863e534f9cb4e218fa81c17c1cc1f6dba77af06f 100644 (file)
--- a/tjbench.c
+++ b/tjbench.c
@@ -60,8 +60,8 @@ int tjErrorLine = -1, tjErrorCode = -1;
     if (strncmp(tjErrorStr, _tjErrorStr, JMSG_LENGTH_MAX) || \
         strncmp(tjErrorMsg, m, JMSG_LENGTH_MAX) || \
         tjErrorCode != _tjErrorCode || tjErrorLine != __LINE__) { \
-      strncpy(tjErrorStr, _tjErrorStr, JMSG_LENGTH_MAX); \
-      strncpy(tjErrorMsg, m, JMSG_LENGTH_MAX); \
+      strncpy(tjErrorStr, _tjErrorStr, JMSG_LENGTH_MAX - 1); \
+      strncpy(tjErrorMsg, m, JMSG_LENGTH_MAX - 1); \
       tjErrorCode = _tjErrorCode; \
       tjErrorLine = __LINE__; \
       printf("WARNING in line %d while %s:\n%s\n", __LINE__, m, _tjErrorStr); \