Message ID | 20240509223213.97389-15-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:46AM +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 | 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); Same comments of prev prev patch. > } > > if ((c = tb[IFACE_ATTR_DHCPV6_NA])) > -- > 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 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]))