From 36f8822c9b06a23b804ce8dcffa5726c7d14fb2f Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 23 Dec 2019 15:53:30 +0100 Subject: [PATCH] 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 --- shared/n-dhcp4/src/n-dhcp4-client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shared/n-dhcp4/src/n-dhcp4-client.c b/shared/n-dhcp4/src/n-dhcp4-client.c index 0bfe48ee95..4fa3d65daa 100644 --- a/shared/n-dhcp4/src/n-dhcp4-client.c +++ b/shared/n-dhcp4/src/n-dhcp4-client.c @@ -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; } }