72a884
From 9825fcbab5c4ddd867432f9922bebfbec7b78af0 Mon Sep 17 00:00:00 2001
72a884
From: Mark Dufour <m.dufour@kopano.com>
72a884
Date: Tue, 14 Feb 2017 10:34:37 +0100
72a884
Subject: [PATCH] [Coverity] fix issue reported for SWIG_Python_FixMethods
72a884
72a884
Fix Coverity issue reported for SWIG_Python_FixMethods:
72a884
72a884
"buffer_size: Calling strncpy with a source string whose length
72a884
(10 chars) is greater than or equal to the size argument (10)
72a884
will fail to null-terminate buff."
72a884
72a884
The issue is only reported for the "swig_ptr: " line, but for
72a884
consistency we replace both occurrences of strncpy with memcpy.
72a884
---
72a884
 Lib/python/pyinit.swg | 4 ++--
72a884
 1 file changed, 2 insertions(+), 2 deletions(-)
72a884
72a884
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
72a884
index 2cc582841..fe45ac941 100644
72a884
--- a/Lib/python/pyinit.swg
72a884
+++ b/Lib/python/pyinit.swg
72a884
@@ -306,9 +306,9 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
72a884
 	  char *ndoc = (char*)malloc(ldoc + lptr + 10);
72a884
 	  if (ndoc) {
72a884
 	    char *buff = ndoc;
72a884
-	    strncpy(buff, methods[i].ml_doc, ldoc);
72a884
+	    memcpy(buff, methods[i].ml_doc, ldoc);
72a884
 	    buff += ldoc;
72a884
-	    strncpy(buff, "swig_ptr: ", 10);
72a884
+	    memcpy(buff, "swig_ptr: ", 10);
72a884
 	    buff += 10;
72a884
 	    SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
72a884
 	    methods[i].ml_doc = ndoc;
72a884
-- 
72a884
2.14.3
72a884