n-dhcp4: handle invalid return codes gracefully

Instead of terminating the program when the dispatch function returns
an invalid return code, log an error message and convert the error
code to a valid, generic one.

https://bugs.archlinux.org/task/64880
(cherry picked from commit 36f8822c9b)
This commit is contained in:
Beniamino Galvani 2019-12-23 15:53:30 +01:00
parent 6017d78734
commit 5586a07f2f

View file

@ -681,7 +681,12 @@ _c_public_ int n_dhcp4_client_dispatch(NDhcp4Client *client) {
/* continue normally */
} else if (r) {
c_assert(r < _N_DHCP4_E_INTERNAL);
if (r >= _N_DHCP4_E_INTERNAL) {
n_dhcp4_c_log(client->config, LOG_ERR,
"invalid internal error code %d after dispatch",
r);
return N_DHCP4_E_INTERNAL;
}
return r;
}
}