[RFC PATCH 13/14] config: clamp dhcpv6_hostid_len
Paul Donald
newtwen+github at gmail.com
Thu May 9 15:30:45 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 | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/config.c b/src/config.c
index f4eaa3b..4d35548 100644
--- a/src/config.c
+++ b/src/config.c
@@ -896,11 +896,12 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
if ((c = tb[IFACE_ATTR_DHCPV6_HOSTID_LEN])) {
uint32_t hostid_len = blobmsg_get_u32(c);
- if (hostid_len >= HOSTID_LEN_MIN && hostid_len <= HOSTID_LEN_MAX)
- iface->dhcpv6_hostid_len = hostid_len;
- else
- syslog(LOG_ERR, "Invalid %s value configured for interface '%s'",
- iface_attrs[IFACE_ATTR_DHCPV6_HOSTID_LEN].name, iface->name);
+ iface->dhcpv6_hostid_len = (hostid_len < HOSTID_LEN_MIN) ?
+ HOSTID_LEN_MIN : (hostid_len > HOSTID_LEN_MAX) ?
+ HOSTID_LEN_MAX : hostid_len;
+ if (!(hostid_len >= HOSTID_LEN_MIN && hostid_len <= HOSTID_LEN_MAX))
+ syslog(LOG_INFO, "Clamped invalid %s value configured for interface '%s' to %d",
+ iface_attrs[IFACE_ATTR_DHCPV6_HOSTID_LEN].name, iface->name, iface->dhcpv6_hostid_len);
}
--
2.44.0
More information about the openwrt-devel
mailing list