mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 14:55:37 +03:00
sd-dhcp6-client: make dhcp6_option_append_fqdn() or friends handle zero length value gracefully
This commit is contained in:
parent
93ed1c0eb9
commit
4ec5b5c778
@ -256,7 +256,6 @@ int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedSet
|
||||
assert(buf);
|
||||
assert(*buf);
|
||||
assert(buflen);
|
||||
assert(vendor_options);
|
||||
|
||||
ORDERED_SET_FOREACH(options, vendor_options) {
|
||||
_cleanup_free_ uint8_t *p = NULL;
|
||||
@ -401,7 +400,9 @@ int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn) {
|
||||
assert(buf);
|
||||
assert(*buf);
|
||||
assert(buflen);
|
||||
assert(fqdn);
|
||||
|
||||
if (isempty(fqdn))
|
||||
return 0;
|
||||
|
||||
buffer[0] = DHCP6_FQDN_FLAG_S; /* Request server to perform AAAA RR DNS updates */
|
||||
|
||||
@ -431,7 +432,9 @@ int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *
|
||||
assert(buf);
|
||||
assert(*buf);
|
||||
assert(buflen);
|
||||
assert(!strv_isempty(user_class));
|
||||
|
||||
if (strv_isempty(user_class))
|
||||
return 0;
|
||||
|
||||
STRV_FOREACH(s, user_class) {
|
||||
size_t len = strlen(*s);
|
||||
@ -463,7 +466,9 @@ int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const
|
||||
assert(buf);
|
||||
assert(*buf);
|
||||
assert(buflen);
|
||||
assert(!strv_isempty(vendor_class));
|
||||
|
||||
if (strv_isempty(vendor_class))
|
||||
return 0;
|
||||
|
||||
enterprise_identifier = htobe32(SYSTEMD_PEN);
|
||||
|
||||
|
@ -77,7 +77,7 @@ int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
|
||||
int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia);
|
||||
int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
|
||||
int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *user_class);
|
||||
int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const *user_class);
|
||||
int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const *vendor_class);
|
||||
int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedSet *vendor_options);
|
||||
|
||||
int dhcp6_option_parse(
|
||||
|
@ -602,29 +602,21 @@ static int client_append_common_options_in_managed_mode(
|
||||
return r;
|
||||
}
|
||||
|
||||
if (client->fqdn) {
|
||||
r = dhcp6_option_append_fqdn(opt, optlen, client->fqdn);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = dhcp6_option_append_fqdn(opt, optlen, client->fqdn);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (client->user_class) {
|
||||
r = dhcp6_option_append_user_class(opt, optlen, client->user_class);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = dhcp6_option_append_user_class(opt, optlen, client->user_class);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (client->vendor_class) {
|
||||
r = dhcp6_option_append_vendor_class(opt, optlen, client->vendor_class);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = dhcp6_option_append_vendor_class(opt, optlen, client->vendor_class);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!ordered_set_isempty(client->vendor_options)) {
|
||||
r = dhcp6_option_append_vendor_option(opt, optlen, client->vendor_options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = dhcp6_option_append_vendor_option(opt, optlen, client->vendor_options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user