aboutgitcodebugslistschat
path: root/dhcpv6.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-04-22 02:30:20 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-04-22 02:30:20 +0200
commit49c766398d47846bd837f5aa83b8bec930e3cf0e (patch)
treef92870d30ca5e4464ea57891bc587b663096e8a5 /dhcpv6.c
parentad60ab1b378da41ba230319eb0e71e3101207a39 (diff)
downloadpasst-49c766398d47846bd837f5aa83b8bec930e3cf0e.tar
passt-49c766398d47846bd837f5aa83b8bec930e3cf0e.tar.gz
passt-49c766398d47846bd837f5aa83b8bec930e3cf0e.tar.bz2
passt-49c766398d47846bd837f5aa83b8bec930e3cf0e.tar.lz
passt-49c766398d47846bd837f5aa83b8bec930e3cf0e.tar.xz
passt-49c766398d47846bd837f5aa83b8bec930e3cf0e.tar.zst
passt-49c766398d47846bd837f5aa83b8bec930e3cf0e.zip
dhcpv6: Subtract option length before returning one option
dhcpv6_opt() needs to subtract option length _before_ returning, so that callers can conveniently pass the remaining length on subsequent calls. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'dhcpv6.c')
-rw-r--r--dhcpv6.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/dhcpv6.c b/dhcpv6.c
index f0217d0..7f566a5 100644
--- a/dhcpv6.c
+++ b/dhcpv6.c
@@ -277,10 +277,11 @@ static struct opt_hdr *dhcpv6_opt(struct opt_hdr *o, uint16_t type, size_t *len)
if (ntohs(o->l) > *len)
return NULL;
+ *len -= ntohs(o->l) + sizeof(struct opt_hdr);
+
if (o->t == type)
return o;
- *len -= ntohs(o->l) + sizeof(struct opt_hdr);
o = (struct opt_hdr *)((uint8_t *)(o + 1) + ntohs(o->l));
}