Message ID | 20240509223213.97389-14-newtwen+github@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | Ansuel Smith |
Headers | show |
Series | odhcpd config value clamping | expand |
On Fri, May 10, 2024 at 12:30:45AM +0200, Paul Donald wrote: > From: Paul Donald <newtwen@gmail.com> > > Attempt to be helpful. > > Signed-off-by: Paul Donald <newtwen@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); Same comments of prev and prev prev patch. > > } > > -- > 2.44.0 > > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
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); }