Skip to content

Commit 7483f75

Browse files
yuwatakeszybz
authored andcommitted
sd-dhcp-server: propagate error on parsing DHCP packet
Otherwise, we silently ignore the received packet and that makes hard to debug issue. (cherry picked from commit 809da72)
1 parent 08c1aff commit 7483f75

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message, siz
11211121

11221122
type = dhcp_option_parse(message, length, parse_request, req, &error_message);
11231123
if (type < 0)
1124-
return 0;
1124+
return type;
11251125

11261126
r = ensure_sane_request(server, req, message);
11271127
if (r < 0)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static void test_message_handler(void) {
146146
test.option_type.code = 0;
147147
test.option_type.length = 0;
148148
test.option_type.type = 0;
149-
assert_se(dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test)) == 0);
149+
assert_se(dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test)) == -ENOMSG);
150150
test.option_type.code = SD_DHCP_OPTION_MESSAGE_TYPE;
151151
test.option_type.length = 1;
152152
test.option_type.type = DHCP_DISCOVER;

0 commit comments

Comments
 (0)