diff options
author | Vladislav Grishenko <themiron@mail.ru> | 2015-07-12 17:02:30 +0500 |
---|---|---|
committer | Vladislav Grishenko <themiron@mail.ru> | 2015-07-12 17:02:30 +0500 |
commit | 4a169b02b003fe50b2bccdf6b8c78a4de245669f (patch) | |
tree | 3371e0606a77a6b8c9c679d1940ca7cc86a41e15 /src | |
parent | d21764d12bb799f89d42c94dc20d4adb6d588077 (diff) | |
download | odhcp6c-4a169b02b003fe50b2bccdf6b8c78a4de245669f.tar.gz |
Avoid solicit for zero-length prefix
Diffstat (limited to 'src')
-rw-r--r-- | src/dhcpv6.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 760f235..a3e0a18 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -272,17 +272,21 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs) for (size_t i = 0; i < n_prefixes; i++) { struct dhcpv6_ia_hdr hdr_ia_pd = { htons(DHCPV6_OPT_IA_PD), - htons(sizeof(hdr_ia_pd) - 4 + sizeof(struct dhcpv6_ia_prefix)), + htons(sizeof(hdr_ia_pd) - 4 + + sizeof(struct dhcpv6_ia_prefix) * !!request_prefixes[i].length), request_prefixes[i].iaid, 0, 0 }; struct dhcpv6_ia_prefix pref = { .type = htons(DHCPV6_OPT_IA_PREFIX), - .len = htons(25), .prefix = request_prefixes[i].length + .len = htons(sizeof(pref) - 4), + .prefix = request_prefixes[i].length }; memcpy(ia_pd + ia_pd_len, &hdr_ia_pd, sizeof(hdr_ia_pd)); ia_pd_len += sizeof(hdr_ia_pd); - memcpy(ia_pd + ia_pd_len, &pref, sizeof(pref)); - ia_pd_len += sizeof(pref); + if (request_prefixes[i].length) { + memcpy(ia_pd + ia_pd_len, &pref, sizeof(pref)); + ia_pd_len += sizeof(pref); + } } } else { struct odhcp6c_entry *e = odhcp6c_get_state(STATE_IA_PD, &ia_pd_entries); |