From c95ae2ba0093742292671fd30a63af15f1b63bc6 Mon Sep 17 00:00:00 2001
From: Evgeny Vereshchagin <evvers@ya.ru>
Date: Sat, 29 Jan 2022 02:08:39 +0000
Subject: [PATCH] sd-dhcp-lease: fix an infinite loop found by the fuzzer

(cherry picked from commit 86b06c666be8b7afb45541d35aa4d0ecb38056d1)
(cherry picked from commit 426807c54b9500b806eaaf50d32c7c936510706c)

Conflict:NA
Reference:https://github.com/systemd/systemd/commit/c95ae2ba0093742292671fd30a63af15f1b63bc6
---
 src/libsystemd-network/sd-dhcp-lease.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 9a0d7f6fea..75aa0c3d2c 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -463,10 +463,8 @@ static int lease_parse_routes(
 
                 route->option = SD_DHCP_OPTION_STATIC_ROUTE;
                 r = in4_addr_default_prefixlen((struct in_addr*) option, &route->dst_prefixlen);
-                if (r < 0) {
-                        log_debug("Failed to determine destination prefix length from class based IP, ignoring");
-                        continue;
-                }
+                if (r < 0)
+                        return -EINVAL;
 
                 assert_se(lease_parse_be32(option, 4, &addr.s_addr) >= 0);
                 route->dst_addr = inet_makeaddr(inet_netof(addr), 0);
-- 
2.33.0

