Resolves: RHEL-46033 - fix segfault with error on subcontainer

Signed-off-by: Josef Ridky <jridky@redhat.com>
This commit is contained in:
Josef Ridky 2024-07-16 10:25:39 +02:00
parent d9b0434c3d
commit 2cb576b643
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,43 @@
diff -urNp a/agent/mibgroup/if-mib/data_access/interface_linux.c b/agent/mibgroup/if-mib/data_access/interface_linux.c
--- a/agent/mibgroup/if-mib/data_access/interface_linux.c 2024-07-16 10:05:43.294653089 +0200
+++ b/agent/mibgroup/if-mib/data_access/interface_linux.c 2024-07-16 10:23:55.392041022 +0200
@@ -609,7 +609,6 @@ netsnmp_arch_interface_container_load(ne
{
FILE *devin;
char line[256];
- netsnmp_interface_entry *entry = NULL;
static char scan_expected = 0;
int fd;
int interfaces = 0;
@@ -690,6 +689,7 @@ netsnmp_arch_interface_container_load(ne
* and retrieve (or create) the corresponding data structure.
*/
while (fgets(line, sizeof(line), devin)) {
+ netsnmp_interface_entry *entry = NULL;
char *stats, *ifstart = line;
u_int flags;
oid if_index;
@@ -733,8 +733,13 @@ netsnmp_arch_interface_container_load(ne
* ip version is to look for ip addresses. If anyone
* knows a better way, put it here!
*/
-#ifdef NETSNMP_ENABLE_IPV6
if_index = netsnmp_arch_interface_index_find(ifstart);
+ if (if_index == 0) {
+ DEBUGMSGTL(("access:interface", "network interface %s is gone",
+ ifstart));
+ continue;
+ }
+#ifdef NETSNMP_ENABLE_IPV6
_arch_interface_has_ipv6(if_index, &flags, addr_container);
#endif
netsnmp_access_interface_ioctl_has_ipv4(fd, ifstart, 0, &flags, &ifc);
@@ -752,7 +757,7 @@ netsnmp_arch_interface_container_load(ne
continue;
}
- entry = netsnmp_access_interface_entry_create(ifstart, 0);
+ entry = netsnmp_access_interface_entry_create(ifstart, if_index);
if(NULL == entry) {
#ifdef NETSNMP_ENABLE_IPV6
netsnmp_access_ipaddress_container_free(addr_container, 0);

View File

@ -10,7 +10,7 @@
Summary: A collection of SNMP protocol tools and libraries
Name: net-snmp
Version: 5.9.1
Release: 16%{?dist}
Release: 17%{?dist}
Epoch: 1
License: BSD
@ -59,6 +59,7 @@ Patch29: net-snmp-5.9-message-severity.patch
Patch30: net-snmp-5.9-rpmdb.patch
Patch31: net-snmp-5.9-CVE-2022-24805-24810.patch
Patch32: net-snmp-5.9.4-kernel-6.7.patch
Patch33: net-snmp-5.9-deleted-iface.patch
# Modern RPM API means at least EL6
Patch101: net-snmp-5.8-modern-rpm-api.patch
@ -243,6 +244,7 @@ cp %{SOURCE10} .
%patch30 -p1 -b .rpmdb
%patch31 -p1 -b .CVE-2022-24805-24810
%patch32 -p1 -b .kernel-6.7-fix
%patch33 -p1 -b .iface
%patch101 -p1 -b .modern-rpm-api
%patch102 -p1
@ -512,6 +514,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make test
%{_libdir}/libnetsnmptrapd*.so.%{soname}*
%changelog
* Tue Jul 16 2024 Josef Ridky <jridky@redhat.com> - 1:5.9.1-17
- fix segfault with error on subcontainer (RHEL-46033)
* Fri Jun 21 2024 Josef Ridky <jridky@redhat.com> - 1:5.9.1-16
- fix unexpected header length in /proc/net/snmp (RHEL-44357)