[m-rev.] diff: Fix strncpy() string truncation warning.

Peter Wang novalazy at gmail.com
Tue Jun 12 10:18:41 AEST 2018


mdbcomp/rtti_access.m:
    Fix gcc -Wstringop-truncation warning for call to strncpy().

diff --git a/mdbcomp/rtti_access.m b/mdbcomp/rtti_access.m
index de54d8550..1269dde88 100644
--- a/mdbcomp/rtti_access.m
+++ b/mdbcomp/rtti_access.m
@@ -380,7 +380,8 @@ get_proc_name(special_proc_label(_, _, _, ProcName , _, _)) = ProcName.
         MR_bool                 found;
 
         if (should_copy_out) {
-            strncpy(out_name_buf, out_name, MR_MAX_VARNAME_SIZE);
+            strncpy(out_name_buf, out_name, sizeof(out_name_buf) - 1);
+            out_name_buf[sizeof(out_name_buf) - 1] = '\\0';
             out_name = (const char *) out_name_buf;
         }
 
-- 
2.17.1



More information about the reviews mailing list