[RFC PATCH 14/14] config: clamp dhcpv6_pd_min_len

Paul Donald newtwen+github at gmail.com
Thu May 9 15:30:46 PDT 2024


From: Paul Donald <newtwen at gmail.com>

Attempt to be helpful.

Signed-off-by: Paul Donald <newtwen at gmail.com>
---
 src/config.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/config.c b/src/config.c
index 4d35548..7484519 100644
--- a/src/config.c
+++ b/src/config.c
@@ -883,11 +883,11 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
 
 	if ((c = tb[IFACE_ATTR_DHCPV6_PD_MIN_LEN])) {
 		uint32_t pd_min_len = blobmsg_get_u32(c);
-		if (pd_min_len != 0 && pd_min_len <= PD_MIN_LEN_MAX)
-			iface->dhcpv6_pd_min_len = pd_min_len;
-		else
-			syslog(LOG_ERR, "Invalid %s value configured for interface '%s'",
-					iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name);
+
+		iface->dhcpv6_pd_min_len = (pd_min_len >= PD_MIN_LEN_MAX) ? PD_MIN_LEN_MAX : pd_min_len;
+		if (pd_min_len >= PD_MIN_LEN_MAX)
+			syslog(LOG_INFO, "Clamped invalid %s value configured for interface '%s' to %d",
+					iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name, iface->dhcpv6_pd_min_len);
 	}
 
 	if ((c = tb[IFACE_ATTR_DHCPV6_NA]))
-- 
2.44.0




More information about the openwrt-devel mailing list