summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/dhcp6-option.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-01-12 22:38:29 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-01-13 00:07:33 +0900
commit019951ec97a98775063271e5f36096ac3ba0b510 (patch)
treeb211d453aa84653c06d738e8222b2ee7c13496cc /src/libsystemd-network/dhcp6-option.c
parent361eb4125d2d7679c71fba157d70d75221970715 (diff)
downloadsystemd-019951ec97a98775063271e5f36096ac3ba0b510.tar.gz
dhcp6: refuse zero length vendor class
Also, fixes the maximum length of the vendor class to UINT16_MAX. Moreover, a memory leak in sd_dhcp6_client_set_request_vendor_class().
Diffstat (limited to 'src/libsystemd-network/dhcp6-option.c')
-rw-r--r--src/libsystemd-network/dhcp6-option.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c
index 8151e66bca..9f47c1bbe4 100644
--- a/src/libsystemd-network/dhcp6-option.c
+++ b/src/libsystemd-network/dhcp6-option.c
@@ -232,16 +232,16 @@ int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *
return dhcp6_option_append(buf, buflen, SD_DHCP6_OPTION_USER_CLASS, total, p);
}
-int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char **vendor_class) {
+int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const *vendor_class) {
_cleanup_free_ uint8_t *p = NULL;
uint32_t enterprise_identifier;
size_t total, offset;
- char **s;
+ char * const *s;
assert(buf);
assert(*buf);
assert(buflen);
- assert(vendor_class);
+ assert(!strv_isempty(vendor_class));
enterprise_identifier = htobe32(SYSTEMD_PEN);
@@ -256,6 +256,9 @@ int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char **vendo
size_t len = strlen(*s);
uint8_t *q;
+ if (len > UINT16_MAX || len == 0)
+ return -EINVAL;
+
q = realloc(p, total + len + 2);
if (!q)
return -ENOMEM;