lwip/0171-IPV6-fix-array-out-of-bounds-in-function-ip6_ntoa_r.patch
yinbin 2e2145bdbc bugfix: fix memery errors detected by cooddy
(cherry picked from commit 2e88021dd3023ae87fd8b57345447f8ca9e5ed83)
2024-10-18 15:03:43 +08:00

26 lines
930 B
Diff

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