1 From 9825fcbab5c4ddd867432f9922bebfbec7b78af0 Mon Sep 17 00:00:00 2001
2 From: Mark Dufour <m.dufour@kopano.com>
3 Date: Tue, 14 Feb 2017 10:34:37 +0100
4 Subject: [PATCH] [Coverity] fix issue reported for SWIG_Python_FixMethods
6 Fix Coverity issue reported for SWIG_Python_FixMethods:
8 "buffer_size: Calling strncpy with a source string whose length
9 (10 chars) is greater than or equal to the size argument (10)
10 will fail to null-terminate buff."
12 The issue is only reported for the "swig_ptr: " line, but for
13 consistency we replace both occurrences of strncpy with memcpy.
15 Signed-off-by: Khem Raj <raj.khem@gmail.com>
16 Status: Backport [https://github.com/swig/swig/pull/898]
18 Lib/python/pyinit.swg | 4 ++--
19 1 file changed, 2 insertions(+), 2 deletions(-)
21 Index: swig-3.0.12/Lib/python/pyinit.swg
22 ===================================================================
23 --- swig-3.0.12.orig/Lib/python/pyinit.swg
24 +++ swig-3.0.12/Lib/python/pyinit.swg
25 @@ -306,9 +306,9 @@ SWIG_Python_FixMethods(PyMethodDef *meth
26 char *ndoc = (char*)malloc(ldoc + lptr + 10);
29 - strncpy(buff, methods[i].ml_doc, ldoc);
30 + memcpy(buff, methods[i].ml_doc, ldoc);
32 - strncpy(buff, "swig_ptr: ", 10);
33 + memcpy(buff, "swig_ptr: ", 10);
35 SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
36 methods[i].ml_doc = ndoc;