You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/11/24 19:51:26 UTC

[GitHub] [tvm] rkimball commented on a change in pull request #6961: Fixes #6960 - strncpy destination size warning

rkimball commented on a change in pull request #6961:
URL: https://github.com/apache/tvm/pull/6961#discussion_r529838485



##########
File path: src/runtime/crt/common/crt_runtime_api.c
##########
@@ -38,7 +38,7 @@
 
 static char g_last_error[1024];
 
-void TVMAPISetLastError(const char* msg) { strncpy(g_last_error, msg, sizeof(g_last_error)); }
+void TVMAPISetLastError(const char* msg) { strncpy(g_last_error, msg, (sizeof(g_last_error)-1)); }

Review comment:
       This won't null-terminate the string if msg >= g_last_error in size.  You can just add g_last_error[sizeof(g_last_error)-1] = 0; to make sure the target string is always null-terminated.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org