]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-server: propagate error on parsing DHCP packet 28731/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Aug 2023 19:58:04 +0000 (04:58 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Aug 2023 20:33:24 +0000 (05:33 +0900)
Otherwise, we silently ignore the received packet and that makes hard to
debug issue.

src/libsystemd-network/sd-dhcp-server.c
src/libsystemd-network/test-dhcp-server.c

index 717dc195c5640d1238d2855e44f5750d3a7f9d3f..0aa500d7d2397757a8a9f26a3e00dd8e2307646a 100644 (file)
@@ -1121,7 +1121,7 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message, siz
 
         type = dhcp_option_parse(message, length, parse_request, req, &error_message);
         if (type < 0)
-                return 0;
+                return type;
 
         r = ensure_sane_request(server, req, message);
         if (r < 0)
index c31a44e37709eb553c912b7779790dad953f0593..a2b46b996271ec60e86ebce8e0a29f570739c113 100644 (file)
@@ -146,7 +146,7 @@ static void test_message_handler(void) {
         test.option_type.code = 0;
         test.option_type.length = 0;
         test.option_type.type = 0;
-        assert_se(dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test)) == 0);
+        assert_se(dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test)) == -ENOMSG);
         test.option_type.code = SD_DHCP_OPTION_MESSAGE_TYPE;
         test.option_type.length = 1;
         test.option_type.type = DHCP_DISCOVER;