[Lldb-commits] [lldb] 1805d1f - [lldb] Fix -Wstringop-truncation in PythonReadline.cpp

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Sat Dec 21 02:33:03 PST 2019


Author: Pavel Labath
Date: 2019-12-21T11:35:26+01:00
New Revision: 1805d1f87d7835b237f85bfb0595d1f411ebf1bf

URL: https://github.com/llvm/llvm-project/commit/1805d1f87d7835b237f85bfb0595d1f411ebf1bf
DIFF: https://github.com/llvm/llvm-project/commit/1805d1f87d7835b237f85bfb0595d1f411ebf1bf.diff

LOG: [lldb] Fix -Wstringop-truncation in PythonReadline.cpp

The size is known and the truncation is deliberate -- use memcpy instead
of strncpy.

Added: 
    

Modified: 
    lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
index 674ec9b6140a..5f6429f5cd0e 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
@@ -67,7 +67,7 @@ simple_readline(FILE *stdin, FILE *stdout, char *prompt)
   char *ret = (char *)PyMem_Malloc(n + 2);
 #endif
   if (ret) {
-    strncpy(ret, line, n);
+    memcpy(ret, line, n);
     free(line);
     ret[n] = '\n';
     ret[n + 1] = '\0';


        


More information about the lldb-commits mailing list