From 92e7f6f0a90baa75fb99c31b614f7534d55654f6 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Wed, 14 May 2025 15:49:41 +0000 Subject: [PATCH] import UBI libnet-1.3-7.el10 --- .gitignore | 2 +- .libnet.metadata | 1 - 170.patch | 100 ++++++++++++++++ libnet-config.patch | 16 +++ SPECS/libnet.spec => libnet.spec | 199 ++++++++++++++++++++----------- sources | 1 + 6 files changed, 248 insertions(+), 71 deletions(-) delete mode 100644 .libnet.metadata create mode 100644 170.patch create mode 100644 libnet-config.patch rename SPECS/libnet.spec => libnet.spec (53%) create mode 100644 sources diff --git a/.gitignore b/.gitignore index e9b5da0..c303b28 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/libnet-1.1.6.tar.gz +libnet-1.3.tar.gz diff --git a/.libnet.metadata b/.libnet.metadata deleted file mode 100644 index c64aac8..0000000 --- a/.libnet.metadata +++ /dev/null @@ -1 +0,0 @@ -dffff71c325584fdcf99b80567b60f8ad985e34c SOURCES/libnet-1.1.6.tar.gz diff --git a/170.patch b/170.patch new file mode 100644 index 0000000..c539ea3 --- /dev/null +++ b/170.patch @@ -0,0 +1,100 @@ +From 79e4b9df5bfa5e5fbaa9f3ad78ff677bf165611f Mon Sep 17 00:00:00 2001 +From: Adrian Reber +Date: Wed, 7 Aug 2024 11:06:19 +0200 +Subject: [PATCH 1/2] libnet_if_addr.c: fix 'Using uninitialized value "rc".' + +This fixes static code analysis report: + + 1. libnet-1.3/src/libnet_if_addr.c:551:5: var_decl: Declaring variable "rc" without initializer. + 8. libnet-1.3/src/libnet_if_addr.c:626:5: uninit_use: Using uninitialized value "rc". + # 624| } + # 625| + # 626|-> return rc; + # 627| } + # 628| + +The code was jumping to the 'end' label without setting rc to anything. +Doing 'return rc' will indeed return an uninitialized value for some +cases. + +This commit removed the 'bad' label and in an error case always jumps to +'end' with rc initialized to -1. + +Signed-off-by: Adrian Reber +--- + src/libnet_if_addr.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/src/libnet_if_addr.c b/src/libnet_if_addr.c +index e0e8b6d4..ab8530c7 100644 +--- a/src/libnet_if_addr.c ++++ b/src/libnet_if_addr.c +@@ -548,7 +548,8 @@ libnet_select_device(libnet_t *l) + { + struct libnet_ifaddr_list *address_list = NULL, *al; + uint32_t addr; +- int c, i, rc; ++ int rc = -1; ++ int c, i; + + if (l == NULL) + { +@@ -600,7 +601,7 @@ libnet_select_device(libnet_t *l) + if (i <= 0) + { + snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): can't find interface for IP %s", __func__, l->device); +- goto bad; ++ goto end; + } + } + else +@@ -610,9 +611,6 @@ libnet_select_device(libnet_t *l) + + good: + rc = 1; +- goto end; +-bad: +- rc = -1; + end: + if (address_list) { + for (i = 0; i < c; i++) + +From ec512f5ea21deabc9631efffb0acfb3e345107bc Mon Sep 17 00:00:00 2001 +From: Adrian Reber +Date: Wed, 7 Aug 2024 11:15:23 +0200 +Subject: [PATCH 2/2] libnet_build_udld.c: fix 'Using uninitialized value "p" + when calling "libnet_pblock_delete"' + +Static code analysis reported: + + 1. libnet-1.3/src/libnet_build_udld.c:11:5: var_decl: Declaring variable "p" without initializer. + 4. libnet-1.3/src/libnet_build_udld.c:119:5: uninit_use_in_call: Using uninitialized value "p" when calling "libnet_pblock_delete". + # 117| return libnet_pblock_update(l, p, h, pblock_type); + # 118| bad: + # 119|-> libnet_pblock_delete(l, p); + # 120| return (-1); + # 121| } + +The function libnet_pblock_delete() checks if p is not NULL, but it is +called before 'p' is uninitialized and it might point to some random +location. Setting it to NULL will skip running libnet_pblock_delete() +cleanup code on a random memory address. + +Signed-off-by: Adrian Reber +--- + src/libnet_build_udld.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/libnet_build_udld.c b/src/libnet_build_udld.c +index 731cffe8..315e6ac5 100644 +--- a/src/libnet_build_udld.c ++++ b/src/libnet_build_udld.c +@@ -8,7 +8,7 @@ const uint8_t value_s, libnet_t * l, libnet_ptag_t ptag) + { + struct libnet_udld_hdr hdr; + uint32_t n, h; +- libnet_pblock_t *p; ++ libnet_pblock_t *p = NULL; + + hdr.tlv__type = tlv_type; + hdr.tlv__length = LIBNET_UDLD_TLV_HDR_SIZE + value_s; diff --git a/libnet-config.patch b/libnet-config.patch new file mode 100644 index 0000000..a8a6bb8 --- /dev/null +++ b/libnet-config.patch @@ -0,0 +1,16 @@ +--- libnet-1.2/libnet-config.in.orig 2021-04-08 14:13:20.095564421 +0200 ++++ libnet-1.2/libnet-config.in 2021-04-08 14:13:42.038730961 +0200 +@@ -12,12 +12,11 @@ + + prefix=@prefix@ + exec_prefix=@exec_prefix@ +-libdir=@libdir@ + includedir=@includedir@ + + libnet_defines="@PKG_CONFIG_DEFINES@" + libnet_cflags="-I${includedir} @PKG_CONFIG_CFLAGS@" +-libnet_libs="-L${libdir} @PKG_CONFIG_LIBS@ -lnet" ++libnet_libs="@PKG_CONFIG_LIBS@ -lnet" + + usage() + { diff --git a/SPECS/libnet.spec b/libnet.spec similarity index 53% rename from SPECS/libnet.spec rename to libnet.spec index 734a50a..e418c5d 100644 --- a/SPECS/libnet.spec +++ b/libnet.spec @@ -1,15 +1,15 @@ -Summary: C library for portable packet creation and injection -Name: libnet -Version: 1.1.6 -Release: 15%{?dist} -License: BSD -Group: System Environment/Libraries -URL: http://www.sourceforge.net/projects/libnet-dev/ -Source: http://downloads.sourceforge.net/libnet-dev/%{name}-%{version}.tar.gz -%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 -BuildRequires: autoconf, automake, libtool -%endif -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +Summary: C library for portable packet creation and injection +Name: libnet +Version: 1.3 +Release: 7%{?dist} +License: BSD-2-Clause AND BSD-3-Clause +URL: https://github.com/libnet/libnet +Source0: https://github.com/libnet/libnet/releases/download/v%{version}/%{name}-%{version}.tar.gz +Patch0: libnet-config.patch +Patch1: https://github.com/libnet/libnet/pull/170.patch +BuildRequires: gcc +BuildRequires: make +BuildRequires: %{_bindir}/pod2man %description Libnet is an API to help with the construction and handling of network @@ -20,88 +20,149 @@ layer and at the link layer as well as a host of supplementary and complementary functionality. %package devel -Summary: Development files for the libnet library -Group: Development/Libraries -Requires: %{name}%{?_isa} = %{version}-%{release} +Summary: Development files for the libnet library +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: pkgconfig %description devel The libnet-devel package includes header files and libraries necessary -for developing programs which use the libnet library. Libnet is very handy -with which to write network tools and network test code. See the manpage -and sample test code for more detailed information. +for developing programs which use the libnet library. Libnet is very +handy with which to write network tools and network test code. See the +man page and sample test code for more detailed information. + +%if 0%{!?_without_doc:1} +%package doc +Summary: Documentation files for the libnet library +BuildArch: noarch +BuildRequires: doxygen +BuildRequires: graphviz + +%description doc +Libnet is an API to help with the construction and handling of network +packets. It provides a portable framework for low-level network packet +writing and handling. This package contains the API documentation for +developing applications that use libnet. +%endif %prep %setup -q -%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 -autoreconf --force --install -%endif - -# Keep the sample directory untouched by make -rm -rf __dist_sample -mkdir __dist_sample -cp -a sample __dist_sample +%patch -P 0 -p1 +%patch -P 1 -p1 +# Avoid library soname bump (https://github.com/libnet/libnet/issues/115) +sed -e 's/-version-info 9:0:0/-version-info 9:0:8/' -i src/Makefile.{am,in} %build -%if 0%{?fedora} < 17 && 0%{?rhel} < 7 -%configure --libdir=/%{_lib} -%else %configure -%endif -make %{?_smp_mflags} +%make_build %install -rm -rf $RPM_BUILD_ROOT -make DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p' install +%make_install INSTALL='install -p' -%if 0%{?fedora} < 17 && 0%{?rhel} < 7 -# Move %{name}.so to %{_libdir}, remove static .a and libtool .la files -rm -f $RPM_BUILD_ROOT/%{_lib}/%{name}.{a,la,so} -pushd $RPM_BUILD_ROOT/%{_lib} -mkdir -p $RPM_BUILD_ROOT%{_libdir} -ln -sf ../../%{_lib}/$(ls %{name}.so.?.?.?) $RPM_BUILD_ROOT%{_libdir}/%{name}.so -popd -%else +# Don't install any libtool .la files rm -f $RPM_BUILD_ROOT%{_libdir}/%{name}.{a,la} -%endif -# Prepare samples directory and perform some fixes -rm -rf __dist_sample/sample/win32 -rm -f __dist_sample/sample/Makefile.{am,in} -sed -e 's@#include "../include/libnet.h"@#include @' \ - __dist_sample/sample/libnet_test.h > __dist_sample/sample/libnet_test.h.new -touch -c -r __dist_sample/sample/libnet_test.h{,.new} -mv -f __dist_sample/sample/libnet_test.h{.new,} +# Clean up for later usage in documentation +rm -rf $RPM_BUILD_ROOT%{_defaultdocdir} -# Remove makefile relics from documentation -rm -f doc/html/Makefile* +# Prepare samples for usage in documentation +rm -rf sample/{Makefile*,win32} +for file in sample/*.[hc]; do + sed \ + -e 's@#include "../include/libnet.h"@#include @' \ + -e 's@#include "../include/config.h"@#include @' \ + $file > $file.new + touch -c -r $file{,.new} + mv -f $file{.new,} +done -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig +%ldconfig_scriptlets %files -%defattr(-,root,root,-) -%doc README doc/CHANGELOG doc/CONTRIB doc/COPYING -%if 0%{?fedora} < 17 && 0%{?rhel} < 7 -/%{_lib}/%{name}.so.* -%else +%license LICENSE +%doc README.md ChangeLog.md %{_libdir}/%{name}.so.* -%endif %files devel -%defattr(-,root,root,-) -%doc doc/CHANGELOG doc/CONTRIB doc/COPYING doc/DESIGN_NOTES doc/MIGRATION doc/PACKET_BUILDING -%doc doc/RAWSOCKET_NON_SEQUITUR doc/TODO doc/html/ __dist_sample/sample/ +%doc doc/MIGRATION.md doc/RAWSOCKET.md sample/ %{_bindir}/%{name}-config %{_libdir}/%{name}.so -%{_includedir}/libnet.h +%{_libdir}/pkgconfig/%{name}.pc +%{_includedir}/%{name}.h %{_includedir}/%{name}/ +%{_mandir}/man1/%{name}*.1* %{_mandir}/man3/%{name}*.3* +%if 0%{!?_without_doc:1} +%files doc +%doc doc/html/ +%endif + %changelog +* Tue Oct 29 2024 Troy Dawson - 1.3-7 +- Bump release for October 2024 mass rebuild: + Resolves: RHEL-64018 + +* Wed Aug 07 2024 Adrian Reber - 1.3-6 +- applied patch to fix static analysis errors + https://github.com/libnet/libnet/pull/170 + +* Tue Aug 06 2024 Adrian Reber - 1.3-5 +- copy gating.yaml from c9s + +* Mon Jun 24 2024 Troy Dawson - 1.3-4 +- Bump release for June 2024 mass rebuild + +* Thu Jan 25 2024 Fedora Release Engineering - 1.3-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Sun Jan 21 2024 Fedora Release Engineering - 1.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Tue Oct 03 2023 Gwyn Ciesla - 1.3-1 +- 1.3 + +* Thu Jul 20 2023 Fedora Release Engineering - 1.2-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Fri Jun 16 2023 Adrian Reber - 1.2-8 +- migrated to SPDX license + +* Thu Jan 19 2023 Fedora Release Engineering - 1.2-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Thu Jul 21 2022 Fedora Release Engineering - 1.2-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Thu Jan 20 2022 Fedora Release Engineering - 1.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Thu Jul 22 2021 Fedora Release Engineering - 1.2-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Thu Apr 08 2021 Adrian Reber - 1.2-3 +- Fix file conflicts with libnet-devel + +* Tue Jan 26 2021 Fedora Release Engineering - 1.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Sat Jan 02 2021 Robert Scheck 1.2-1 +- Upgrade to 1.2 (#1912031) + +* Tue Jul 28 2020 Fedora Release Engineering - 1.1.6-20 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Wed Jan 29 2020 Fedora Release Engineering - 1.1.6-19 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jul 25 2019 Fedora Release Engineering - 1.1.6-18 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Fri Feb 01 2019 Fedora Release Engineering - 1.1.6-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Jul 13 2018 Fedora Release Engineering - 1.1.6-16 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + * Wed Feb 07 2018 Fedora Release Engineering - 1.1.6-15 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild @@ -207,11 +268,11 @@ rm -rf $RPM_BUILD_ROOT - spec file cleanup * Fri Aug 26 2005 Patrice Dumas 1.1.2.1-4 -- use pushd and popd (from Oliver Falk) +- use pushd and popd (from Oliver Falk) * Mon Aug 22 2005 Patrice Dumas 1.1.2.1-3 - Correct dos end of lines -- add in devel: Provides: %%{name} = %%{version}-%%{release} +- add in devel: Provides: %%{name} = %%{version}-%%{release} * Fri Aug 12 2005 Patrice Dumas 1.1.2.1-2 - put everything in a devel subpackage diff --git a/sources b/sources new file mode 100644 index 0000000..a8be91c --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (libnet-1.3.tar.gz) = c434327108b61e73b61acc5f2b346d049ab5d58e494db21971368eac733a9a0a3e9d95e0b4523c20629b02ed0feef086c50c582719635f21e980c440d55dd462