|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 44481a8b537839cd9ffead4d261491641f5b5260 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Sat, 30 Aug 2014 18:31:21 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] sd-dhcp6-client: properly calculate buffer size when parsing
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
options
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Also make pointer calculations more explicit so they are
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
easier to understand.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-network/sd-dhcp6-client.c | 5 ++++-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-network/test-dhcp6-client.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
2 files changed, 5 insertions(+), 2 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 342a231413..6860c66858 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-network/sd-dhcp6-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-network/sd-dhcp6-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -583,12 +583,15 @@ static int client_parse_message(sd_dhcp6_client *client,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
DHCP6Message *message, size_t len,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
sd_dhcp6_lease *lease) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- uint8_t *optval, *option = (uint8_t *)(message + 1), *id = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ uint8_t *optval, *option, *id = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint16_t optcode, status;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t optlen, id_len;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
bool clientid = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
be32_t iaid_lease;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ option = (uint8_t *)message + sizeof(DHCP6Message);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ len -= sizeof(DHCP6Message);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
while ((r = dhcp6_option_parse(&option, &len, &optcode, &optlen,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
&optval)) >= 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
switch (optcode) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 259db33bcd..d102a796b4 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-network/test-dhcp6-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-network/test-dhcp6-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -205,7 +205,7 @@ static uint8_t msg_reply[173] = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static int test_advertise_option(sd_event *e) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_dhcp6_lease_free_ sd_dhcp6_lease *lease = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
DHCP6Message *advertise = (DHCP6Message *)msg_advertise;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- uint8_t *optval, *opt = &msg_advertise[sizeof(DHCP6Message)];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ uint8_t *optval, *opt = msg_advertise + sizeof(DHCP6Message);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint16_t optcode;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t optlen, len = sizeof(msg_advertise) - sizeof(DHCP6Message);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
be32_t val;
|