-
Notifications
You must be signed in to change notification settings - Fork 7.6k
mgmt: hawkbit: domain name buffer length and add check #89497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgmt: hawkbit: domain name buffer length and add check #89497
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also after line 287 in hawkbit.c
so that the length is not checkt that strict of the server_addr:
line 288: if (len > sizeof(hb_cfg.server_addr)) {
line 292: rc = read_cb(cb_arg, &hb_cfg.server_addr, len);
line 361: (void)cb("hawkbit/server_addr", &hb_cfg.server_addr, strlen(hb_cfg.server_addr));
The hawkbit subsystem was erroneously using DNS_MAX_NAME_SIZE as the maximum query length. This limited query strings to only 20 bytes, truncating many domain names. Signed-off-by: Neal Jackson <[email protected]>
7628398
to
588b472
Compare
92a2b9c
to
5e9ba77
Compare
This commit adds a `strnlen` length check for `server_addr` to ensure that it will not be truncated and result in a silent failure. Instead, the call to `hawkbit_set_config` will return -EINVAL if the supplied `server_addr` is too long for the internal buffer. Signed-off-by: Neal Jackson <[email protected]>
5e9ba77
to
d0510f4
Compare
d0510f4
to
d891ece
Compare
Simplify length checks by using sizeof for the server_addr array. Signed-off-by: Neal Jackson <[email protected]>
This commit removes the requirement for DNS_RESOLVER. If DNS_RESOLVER is enabled, hawkbit uses `CONFIG_DNS_RESOLVER_MAX_QUERY_LEN` for the server_addr buffer, if disabled it uses `CONFIG_INET6_ADDRSTRLEN`. This adheres to zephyrproject-rtos#89533 which removes the requirement for DNS_RESOLVER. Signed-off-by: Neal Jackson <[email protected]>
d891ece
to
acf4bee
Compare
Are there any other changes that are required for this pull request? |
Hi @nealjack! To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge. Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁 |
This PR fixes the
hb_cfg.server_addr
buffer and adds a length check when setting this value.Hawkbit uses
DNS_MAX_NAME_SIZE
for its internal buffer which is intended for a DNS response, not the query. By defaultDNS_MAX_NAME_SIZE
is only 20 bytes and results in truncation for a domain name longer than that. For example, the domain name hawkbit.yourcompany.com would be truncated and fail to resolve. The KconfigDNS_RESOLVER_MAX_QUERY_LEN
is the correct macro to use here for a query, and is by default 256 bytes, in line with RFC1035.Since
DNS_RESOLVER_MAX_QUERY_LEN
is adjustable,hawkbit_set_config
also requires a length check to ensure that any domain name that is passed in can be fit in its internal buffer. This prevents silent truncation of the domain name.