!1321 [sync] PR-1315: bugfix: fix memery errors detected by cooddy

From: @openeuler-sync-bot 
Reviewed-by: @jiangheng12 
Signed-off-by: @jiangheng12
This commit is contained in:
openeuler-ci-bot 2024-10-21 08:43:45 +00:00 committed by Gitee
commit d1e51dbec9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 102 additions and 1 deletions

View File

@ -0,0 +1,25 @@
From d451214b0761977f016ef0d7b248847d5cc643f5 Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Sat, 12 Oct 2024 17:36:27 +0800
Subject: [PATCH 1/3] IPV6: Enable IPV6_FRAG_COPYHEADER macro to adapt 64bit
env
---
src/include/lwipopts.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h
index c3ecb21..c46dce9 100644
--- a/src/include/lwipopts.h
+++ b/src/include/lwipopts.h
@@ -187,6 +187,7 @@
#define LWIP_IPV6 1
#define IP6_HLEN 40
#define LWIP_IPV6_SCOPES 1
+#define IPV6_FRAG_COPYHEADER 1
/*
---------------------------------
--
2.34.1

View File

@ -0,0 +1,25 @@
From 99400e4659fbd84adecdf621f213e0f7f329556c Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Mon, 14 Oct 2024 09:19:26 +0800
Subject: [PATCH 2/3] IPV6: fix array out of bounds in function ip6_ntoa_r
---
src/core/ipv6/ip6_addr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/ipv6/ip6_addr.c b/src/core/ipv6/ip6_addr.c
index 6e0ac86..dfcc5b1 100644
--- a/src/core/ipv6/ip6_addr.c
+++ b/src/core/ipv6/ip6_addr.c
@@ -278,7 +278,7 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen)
}
break;
}
- if (empty_block_flag == 0) {
+ if (empty_block_flag == 0 && current_block_value < 7) {
/* generate empty block "::", but only if more than one contiguous zero block,
* according to current formatting suggestions RFC 5952. */
next_block_value = lwip_htonl(addr->addr[(current_block_index + 1) >> 1]);
--
2.34.1

View File

@ -0,0 +1,43 @@
From c73d8f324d14c2433d2a59724c2ea4ff7a9ea979 Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Mon, 14 Oct 2024 15:45:07 +0800
Subject: [PATCH] IPV6: add group check while mld6 schedule a report
---
src/core/ipv6/mld6.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/core/ipv6/mld6.c b/src/core/ipv6/mld6.c
index 3aecb35..ffa2faf 100644
--- a/src/core/ipv6/mld6.c
+++ b/src/core/ipv6/mld6.c
@@ -292,11 +292,14 @@ mld6_input(struct pbuf *p, struct netif *inp)
ip6_addr_copy(group_addr, mld_v2_hdr->multicast_address);
group = mld6_lookfor_group(inp, &group_addr);
+ if (group == NULL) {
+ MLD6_STATS_INC(mld6.drop);
+ break;
+ }
+
if (0 == src_num) {
- if (group != NULL) {
- /* Schedule a report. */
- mld6_v2_delayed_report(group, lwip_ntohs(mld_v2_hdr->max_resp_delay));
- }
+ /* Schedule a report. */
+ mld6_v2_delayed_report(group, lwip_ntohs(mld_v2_hdr->max_resp_delay));
} else {
src_buf = (ip6_addr_p_t *)mem_malloc(src_buf_size);
if (src_buf == NULL) {
@@ -310,6 +313,7 @@ mld6_input(struct pbuf *p, struct netif *inp)
/* We interest! */
mld6_v2_delayed_report(group, lwip_ntohs(mld_v2_hdr->max_resp_delay));
}
+ mem_free(src_buf);
}
}
}
--
2.34.1

View File

@ -4,7 +4,7 @@
Summary: lwip is a small independent implementation of the TCP/IP protocol suite
Name: lwip
Version: 2.2.0
Release: 59
Release: 60
License: BSD
URL: http://savannah.nongnu.org/projects/lwip/
Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip
@ -181,6 +181,9 @@ Patch9165: 0166-cleancode-rename-log-level.patch
Patch9166: 0167-lwip-add-pingpong-mode-support.patch
Patch9167: 0168-lwip-adapt-interrupt-mode.patch
Patch9168: 0169-pingpong-fix-send-dup-ack.patch
Patch9169: 0170-IPV6-Enable-IPV6_FRAG_COPYHEADER-macro-to-adapt-64bi.patch
Patch9170: 0171-IPV6-fix-array-out-of-bounds-in-function-ip6_ntoa_r.patch
Patch9171: 0172-IPV6-add-group-check-while-mld6-schedule-a-report.patch
BuildRequires: gcc-c++ dos2unix dpdk-devel
@ -210,6 +213,11 @@ cd %{_builddir}/%{name}-%{version}/src
%{_libdir}/liblwip.a
%changelog
* Mon Oct 14 2024 yinbin <yinbin8@huawei.com> - 2.2.0-60
- IPV6: Enable IPV6_FRAG_COPYHEADER macro to adapt 64bit
- IPV6: fix array out of bounds in function ip6_ntoa_r
- IPV6: add group check while mld6 schedule a report
* Mon Sep 30 2024 jiangheng <jiangheng14@huawei.com> - 2.2.0-59
- pingpong: fix send dup ack in fast timer