[oe-commits] [openembedded-core] 19/46: swig: Replace strncpy with memcpy

git at git.openembedded.org git at git.openembedded.org
Tue May 15 09:57:48 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master
in repository openembedded-core.

commit 828ae03da4468b4c672f71e1b4cac9b8fff73d2d
Author: Khem Raj <raj.khem at gmail.com>
AuthorDate: Wed May 9 13:24:22 2018 -0700

    swig: Replace strncpy with memcpy
    
    gcc8 is detecting string truncations when swig is
    used in other packages
    
    Signed-off-by: Khem Raj <raj.khem at gmail.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 ...x-issue-reported-for-SWIG_Python_FixMetho.patch | 36 ++++++++++++++++++++++
 meta/recipes-devtools/swig/swig_3.0.12.bb          |  1 +
 2 files changed, 37 insertions(+)

diff --git a/meta/recipes-devtools/swig/swig/swig-3.0.12-Coverity-fix-issue-reported-for-SWIG_Python_FixMetho.patch b/meta/recipes-devtools/swig/swig/swig-3.0.12-Coverity-fix-issue-reported-for-SWIG_Python_FixMetho.patch
new file mode 100644
index 0000000..eab50fc
--- /dev/null
+++ b/meta/recipes-devtools/swig/swig/swig-3.0.12-Coverity-fix-issue-reported-for-SWIG_Python_FixMetho.patch
@@ -0,0 +1,36 @@
+From 9825fcbab5c4ddd867432f9922bebfbec7b78af0 Mon Sep 17 00:00:00 2001
+From: Mark Dufour <m.dufour at kopano.com>
+Date: Tue, 14 Feb 2017 10:34:37 +0100
+Subject: [PATCH] [Coverity] fix issue reported for SWIG_Python_FixMethods
+
+Fix Coverity issue reported for SWIG_Python_FixMethods:
+
+"buffer_size: Calling strncpy with a source string whose length
+(10 chars) is greater than or equal to the size argument (10)
+will fail to null-terminate buff."
+
+The issue is only reported for the "swig_ptr: " line, but for
+consistency we replace both occurrences of strncpy with memcpy.
+---
+Signed-off-by: Khem Raj <raj.khem at gmail.com>
+Status: Backport [https://github.com/swig/swig/pull/898]
+
+ Lib/python/pyinit.swg | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+Index: swig-3.0.12/Lib/python/pyinit.swg
+===================================================================
+--- swig-3.0.12.orig/Lib/python/pyinit.swg
++++ swig-3.0.12/Lib/python/pyinit.swg
+@@ -306,9 +306,9 @@ SWIG_Python_FixMethods(PyMethodDef *meth
+ 	  char *ndoc = (char*)malloc(ldoc + lptr + 10);
+ 	  if (ndoc) {
+ 	    char *buff = ndoc;
+-	    strncpy(buff, methods[i].ml_doc, ldoc);
++	    memcpy(buff, methods[i].ml_doc, ldoc);
+ 	    buff += ldoc;
+-	    strncpy(buff, "swig_ptr: ", 10);
++	    memcpy(buff, "swig_ptr: ", 10);
+ 	    buff += 10;
+ 	    SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
+ 	    methods[i].ml_doc = ndoc;
diff --git a/meta/recipes-devtools/swig/swig_3.0.12.bb b/meta/recipes-devtools/swig/swig_3.0.12.bb
index 15f7348..429840b 100644
--- a/meta/recipes-devtools/swig/swig_3.0.12.bb
+++ b/meta/recipes-devtools/swig/swig_3.0.12.bb
@@ -3,6 +3,7 @@ require ${BPN}.inc
 SRC_URI += "file://0001-Use-proc-self-exe-for-swig-swiglib-on-non-Win32-plat.patch \
             file://0001-configure-use-pkg-config-for-pcre-detection.patch \
             file://0001-Add-Node-7.x-aka-V8-5.2-support.patch \
+            file://swig-3.0.12-Coverity-fix-issue-reported-for-SWIG_Python_FixMetho.patch \
            "
 SRC_URI[md5sum] = "82133dfa7bba75ff9ad98a7046be687c"
 SRC_URI[sha256sum] = "7cf9f447ae7ed1c51722efc45e7f14418d15d7a1e143ac9f09a668999f4fc94d"

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list