commit:     cd67e88af10917a04712c42f8f9a535f0dae8562
Author:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  4 22:36:15 2021 +0000
Commit:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Wed Aug  4 22:36:58 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cd67e88a

sys-libs/libvpd: revbump, add gcc11 compile fixes

Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>

 sys-libs/libvpd/files/2.2.8-gcc11.patch            | 84 ++++++++++++++++++++++
 sys-libs/libvpd/files/2.2.8-warnings.patch         | 52 ++++++++++++++
 ...{libvpd-2.2.8.ebuild => libvpd-2.2.8-r1.ebuild} |  7 +-
 3 files changed, 142 insertions(+), 1 deletion(-)

diff --git a/sys-libs/libvpd/files/2.2.8-gcc11.patch 
b/sys-libs/libvpd/files/2.2.8-gcc11.patch
new file mode 100644
index 00000000000..7e09f8329bb
--- /dev/null
+++ b/sys-libs/libvpd/files/2.2.8-gcc11.patch
@@ -0,0 +1,84 @@
+From 83ccb994e30364c0703d7b8c15817d56b42da2e6 Mon Sep 17 00:00:00 2001
+From: Kamalesh Babulal <[email protected]>
+Date: Wed, 7 Apr 2021 14:11:41 +0530
+Subject: [PATCH] Remove dynamic exception specification
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Tomasz Kłoczko reported that the build fails, while compiling
+with GCC 11:
+
+In file included from src/vpdretriever.cpp:25:
+./src/libvpd-2/vpdretriever.hpp:62:33: error: ISO C++17 does not allow dynamic 
exception specifications
+   62 |                                 throw( VpdException& );
+      |                                 ^~~~~
+./src/libvpd-2/vpdretriever.hpp:74:33: error: ISO C++17 does not allow dynamic 
exception specifications
+   74 |                                 throw( VpdException& );
+      |                                 ^~~~~
+src/vpdretriever.cpp:50:37: error: ISO C++17 does not allow dynamic exception 
specifications
+   50 |                 string dbFileName ) throw( VpdException& )
+      |                                     ^~~~~
+src/vpdretriever.cpp:62:39: error: ISO C++17 does not allow dynamic exception 
specifications
+   62 |         VpdRetriever::VpdRetriever( ) throw( VpdException& )
+      |                                       ^~~~~
+make: *** [Makefile:660: src/vpdretriever.lo] Error 1
+
+As part of
+http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0003r5.html,
+the dynamic exception specification have been removed. Remove the
+throw specifier, to specify that the function might throw an exception.
+
+Signed-off-by: Kamalesh Babulal <[email protected]>
+Signed-off-by: Vasant Hegde <[email protected]>
+---
+ src/libvpd-2/vpdretriever.hpp | 6 ++----
+ src/vpdretriever.cpp          | 4 ++--
+ 2 files changed, 4 insertions(+), 6 deletions(-)
+
+diff --git a/src/libvpd-2/vpdretriever.hpp b/src/libvpd-2/vpdretriever.hpp
+index 0d91ac4..1be2664 100644
+--- a/src/libvpd-2/vpdretriever.hpp
++++ b/src/libvpd-2/vpdretriever.hpp
+@@ -58,8 +58,7 @@ namespace lsvpd
+                        * @param dbFileName
+                        *   The file name for the VPD database.
+                        */
+-                      VpdRetriever( string envDir, string dbFileName )
+-                              throw( VpdException& );
++                      VpdRetriever( string envDir, string dbFileName );
+                       
+                       /**
+                        * Builds A VpdRetriever object that can be used for 
reading the
+@@ -70,8 +69,7 @@ namespace lsvpd
+                        * this constructor, there were serious underlying 
issues that
+                        * are not recoverable.  Uses the default dir and 
filename
+                        */
+-                      VpdRetriever( )
+-                              throw( VpdException& );
++                      VpdRetriever( );
+                       ~VpdRetriever( );
+ 
+                       /**
+diff --git a/src/vpdretriever.cpp b/src/vpdretriever.cpp
+index 9f7e7a0..470047e 100644
+--- a/src/vpdretriever.cpp
++++ b/src/vpdretriever.cpp
+@@ -47,7 +47,7 @@ namespace lsvpd
+       const string VpdRetriever::UDEV_NOTIFY_FILE ( "/run/run.vpdupdate" );
+ 
+       VpdRetriever::VpdRetriever( string envDir,
+-              string dbFileName ) throw( VpdException& )
++              string dbFileName )
+       {
+               try {
+                       db = new VpdDbEnv( envDir, dbFileName, true );
+@@ -59,7 +59,7 @@ namespace lsvpd
+               }
+       }
+       
+-      VpdRetriever::VpdRetriever( ) throw( VpdException& )
++      VpdRetriever::VpdRetriever( )
+       {
+               struct stat vpd_stat,udev_stat;
+               const string vpddb = VpdRetriever::DEFAULT_DIR + 
VpdRetriever::DEFAULT_FILE;

diff --git a/sys-libs/libvpd/files/2.2.8-warnings.patch 
b/sys-libs/libvpd/files/2.2.8-warnings.patch
new file mode 100644
index 00000000000..1419de3dda4
--- /dev/null
+++ b/sys-libs/libvpd/files/2.2.8-warnings.patch
@@ -0,0 +1,52 @@
+From 72b75e1976b50372f07271a5235ee8e9c75bdac4 Mon Sep 17 00:00:00 2001
+From: Kamalesh Babulal <[email protected]>
+Date: Mon, 21 Jun 2021 11:42:02 +0530
+Subject: [PATCH] vpddbenv_c: fix compile warnings
+
+src/vpddbenv_c.c: In function 'new_vpddbenv':
+src/vpddbenv_c.c:56:17: warning: 'strncat' specified bound 1 equals source 
length [-Wstringop-overflow=]
+   56 |                 strncat( ret->fullPath, "/" , 1 );
+      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src/vpddbenv_c.c:58:17: warning: 'strncat' accessing between 258 and 
9223372036854775804 bytes at offsets 514 and 257 may overlap 1 byte at offset 
514 [-Wrestrict]
+   58 |                 strncat( ret->fullPath, ret->dbFileName, 
strlen(ret->dbFileName) );
+      |
+                        
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+While compiling the code with GCC-11 (Fedora 34), the GCC complains
+about src string length and N bytes mentioned in the strncat() are of
+same length. It gets suspicious, when strncat() mimics strcat(), the
+strcat() was replaced using strncat() by the commit 38de4e65205
+("libvpd: Convert strcat to strncat") as part of secure coding.
+
+refactor the code using snprintf(), making the code lean and keep the
+GCC happy as well.
+
+Signed-off-by: Kamalesh Babulal <[email protected]>
+Signed-off-by: Vasant Hegde <[email protected]>
+---
+ src/vpddbenv_c.c | 12 ++++--------
+ 1 file changed, 4 insertions(+), 8 deletions(-)
+
+diff --git a/src/vpddbenv_c.c b/src/vpddbenv_c.c
+index 96aecd3..bae36e9 100644
+--- a/src/vpddbenv_c.c
++++ b/src/vpddbenv_c.c
+@@ -50,14 +50,10 @@ struct vpddbenv * new_vpddbenv( const char *dir, const 
char *file )
+               ret->dbFileName[MAX_NAME_LENGTH] = '\0';
+       }
+ 
+-      strncpy( ret->fullPath, ret->envDir , FULL_PATH_SIZE - 1);
+-
+-      if (strlen(ret->fullPath) + 1 < FULL_PATH_SIZE)
+-              strncat( ret->fullPath, "/" , 1 );
+-      if (strlen(ret->fullPath) + strlen(ret->dbFileName) < FULL_PATH_SIZE)
+-              strncat( ret->fullPath, ret->dbFileName, strlen 
(ret->dbFileName) );
+-
+-      ret->fullPath[FULL_PATH_SIZE - 1] = '\0';
++      if ( ( strlen( ret->envDir ) + strlen( ret->dbFileName ) + 1 ) <
++                      FULL_PATH_SIZE )
++              snprintf( ret->fullPath, FULL_PATH_SIZE,
++                              "%s/%s", ret->envDir, ret->dbFileName );
+       
+       rc = sqlite3_open( ret->fullPath, &(ret->db) );
+       if( rc != SQLITE_OK )

diff --git a/sys-libs/libvpd/libvpd-2.2.8.ebuild 
b/sys-libs/libvpd/libvpd-2.2.8-r1.ebuild
similarity index 87%
rename from sys-libs/libvpd/libvpd-2.2.8.ebuild
rename to sys-libs/libvpd/libvpd-2.2.8-r1.ebuild
index 0c38cecb19f..3b69e327edd 100644
--- a/sys-libs/libvpd/libvpd-2.2.8.ebuild
+++ b/sys-libs/libvpd/libvpd-2.2.8-r1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -18,6 +18,11 @@ DEPEND="
 "
 RDEPEND="${DEPEND}"
 
+PATCHES=(
+       "${FILESDIR}/2.2.8-gcc11.patch"
+       "${FILESDIR}/2.2.8-warnings.patch"
+)
+
 src_prepare() {
        default
        eautoreconf

Reply via email to