Blob Blame History Raw
From 7703c08ef660b56ae3d2a2f47c0d21383c967d46 Mon Sep 17 00:00:00 2001
From: Nick Owens <mischief@coreos.com>
Date: Thu, 9 Jul 2015 12:51:55 -0700
Subject: [PATCH] sd-dhcp-lease: fix handling of multiple routers

currently if a dhcp server sends more than one router, sd-dhcp-lease
does not copy the ip because it assumes it will only ever be 4 bytes. a
dhcp server could send more than one ip in the router list, so we should
copy the first one and ignore the rest of the bytes.

(cherry picked from commit a05185279bfc2420f60dc2a061d50bfcb646be70)
---
 src/libsystemd-network/sd-dhcp-lease.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 3c632b6774..9fc5788910 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -441,7 +441,8 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
                 break;
 
         case DHCP_OPTION_ROUTER:
-                lease_parse_be32(option, len, &lease->router);
+                if(len >= 4)
+                        lease_parse_be32(option, 4, &lease->router);
 
                 break;