sd-dhcp-server: propagate error on parsing DHCP packet

Otherwise, we silently ignore the received packet and that makes hard to
debug issue.
This commit is contained in:
Yu Watanabe
2023-08-09 05:33:24 +09:00
parent 7b1fac1e52
commit 809da721f0
2 changed files with 2 additions and 2 deletions
+1 -1
View 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)
+1 -1
View 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;