diff options
| author | Michael Biebl <biebl@debian.org> | 2020-05-08 21:40:53 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2020-05-08 21:40:53 +0200 |
| commit | d460892bbfece74fb6d3cd846bf6ef548290be41 (patch) | |
| tree | 0474e5be0b5e5fac0d2f3a1e554382e8d1aa6397 /shared/n-dhcp4/src | |
| parent | 1e5977b62f896e844b548c3007ace9e1dfa7f9ed (diff) | |
New upstream version 1.24.0 upstream/1.24.0
Diffstat (limited to 'shared/n-dhcp4/src')
| -rw-r--r-- | shared/n-dhcp4/src/n-dhcp4-c-connection.c | 29 | ||||
| -rw-r--r-- | shared/n-dhcp4/src/n-dhcp4-c-probe.c | 1 |
2 files changed, 22 insertions, 8 deletions
diff --git a/shared/n-dhcp4/src/n-dhcp4-c-connection.c b/shared/n-dhcp4/src/n-dhcp4-c-connection.c index a5c8ea66..30514e28 100644 --- a/shared/n-dhcp4/src/n-dhcp4-c-connection.c +++ b/shared/n-dhcp4/src/n-dhcp4-c-connection.c @@ -1136,6 +1136,13 @@ int n_dhcp4_c_connection_dispatch_timer(NDhcp4CConnection *connection, return 0; } +/* + * Returns: + * 0 on success + * N_DHCP4_E_MALFORMED if a malformed packet was received + * N_DHCP4_E_UNEXPECTED if the packet received contains unexpected data + * N_DHCP4_E_AGAIN if there was another error (non fatal for the client) + */ int n_dhcp4_c_connection_dispatch_io(NDhcp4CConnection *connection, NDhcp4Incoming **messagep) { _c_cleanup_(n_dhcp4_incoming_freep) NDhcp4Incoming *message = NULL; @@ -1150,10 +1157,11 @@ int n_dhcp4_c_connection_dispatch_io(NDhcp4CConnection *connection, connection->scratch_buffer, sizeof(connection->scratch_buffer), &message); - if (r) + if (!r) + break; + else if (r == N_DHCP4_E_MALFORMED) return r; - - break; + return N_DHCP4_E_AGAIN; case N_DHCP4_C_CONNECTION_STATE_DRAINING: r = n_dhcp4_c_socket_packet_recv(connection->fd_packet, connection->scratch_buffer, @@ -1161,8 +1169,10 @@ int n_dhcp4_c_connection_dispatch_io(NDhcp4CConnection *connection, &message); if (!r) break; - else if (r != N_DHCP4_E_AGAIN) + else if (r == N_DHCP4_E_MALFORMED) return r; + else if (r != N_DHCP4_E_AGAIN) + return N_DHCP4_E_AGAIN; /* * The UDP socket is open and the packet socket has been shut down @@ -1180,18 +1190,21 @@ int n_dhcp4_c_connection_dispatch_io(NDhcp4CConnection *connection, connection->scratch_buffer, sizeof(connection->scratch_buffer), &message); - if (r) + if (!r) + break; + else if (r == N_DHCP4_E_MALFORMED) return r; - - break; + return N_DHCP4_E_AGAIN; default: abort(); return -ENOTRECOVERABLE; } r = n_dhcp4_c_connection_verify_incoming(connection, message, &type); - if (r) + if (r == N_DHCP4_E_MALFORMED || r == N_DHCP4_E_UNEXPECTED) return r; + else if (r != 0) + return N_DHCP4_E_AGAIN; if (type == N_DHCP4_MESSAGE_OFFER || type == N_DHCP4_MESSAGE_ACK) { n_dhcp4_c_log(connection->client_config, LOG_INFO, diff --git a/shared/n-dhcp4/src/n-dhcp4-c-probe.c b/shared/n-dhcp4/src/n-dhcp4-c-probe.c index e4477a7c..5e971298 100644 --- a/shared/n-dhcp4/src/n-dhcp4-c-probe.c +++ b/shared/n-dhcp4/src/n-dhcp4-c-probe.c @@ -1242,6 +1242,7 @@ int n_dhcp4_client_probe_dispatch_io(NDhcp4ClientProbe *probe, uint32_t events) return 0; } + abort(); return r; } |