Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 9/9] swig: Replace strncpy with memcpy
Date: Wed,  9 May 2018 13:24:22 -0700	[thread overview]
Message-ID: <20180509202422.22501-9-raj.khem@gmail.com> (raw)
In-Reply-To: <20180509202422.22501-1-raj.khem@gmail.com>

gcc8 is detecting string truncations when swig is
used in other packages

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...ue-reported-for-SWIG_Python_FixMetho.patch | 36 +++++++++++++++++++
 meta/recipes-devtools/swig/swig_3.0.12.bb     |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 meta/recipes-devtools/swig/swig/swig-3.0.12-Coverity-fix-issue-reported-for-SWIG_Python_FixMetho.patch

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 0000000000..eab50fc7ef
--- /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@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@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 15f7348681..429840bde1 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"
-- 
2.17.0



      parent reply	other threads:[~2018-05-09 20:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 20:24 [PATCH 1/9] pbzip2: Fix C++11 warnings found with clang Khem Raj
2018-05-09 20:24 ` [PATCH 2/9] alsa-tools: Update to 1.1.6 Khem Raj
2018-05-09 20:24 ` [PATCH 3/9] alsa-lib: Upgrade " Khem Raj
2018-05-09 20:24 ` [PATCH V2 4/9] mdadm: Fix build with gcc8 Khem Raj
2018-05-09 20:24 ` [PATCH 5/9] Disable using GST_GL if gst does not enable it Khem Raj
2018-05-09 20:24 ` [PATCH 6/9] strace: Upgrade to 4.22 Khem Raj
2018-05-10 22:29   ` [PATCH] strace: remove -fno-omit-frame-pointer from DEBUG_OPTIMIZATION when ptest is enabled Martin Jansa
2018-05-09 20:24 ` [PATCH 7/9] gdb: Upgrade to 8.1 release Khem Raj
2018-05-10 11:13   ` Burton, Ross
2018-05-10 16:59     ` Khem Raj
2018-05-09 20:24 ` [PATCH 8/9] libgpg-error: Upgrade 1.28 -> 1.31 Khem Raj
2018-05-09 20:24 ` Khem Raj [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180509202422.22501-9-raj.khem@gmail.com \
    --to=raj.khem@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox