odhcpd: call handle_error when socket error can be retrieved
authorHans Dedecker <dedeckeh@gmail.com>
Wed, 13 Jun 2018 20:15:51 +0000 (22:15 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 13 Jun 2018 20:16:52 +0000 (22:16 +0200)
Detected by Coverity in CID1412300

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/odhcpd.c

index 7c6c144112e076efc37ac2c38bb55fb3c33ef3d5..9ab849aa75086a9e8d9b8b50b7f97284ecf45115 100644 (file)
@@ -320,9 +320,9 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even
        if (u->error) {
                int ret = -1;
                socklen_t ret_len = sizeof(ret);
-               getsockopt(u->fd, SOL_SOCKET, SO_ERROR, &ret, &ret_len);
+
                u->error = false;
-               if (e->handle_error)
+               if (e->handle_error && getsockopt(u->fd, SOL_SOCKET, SO_ERROR, &ret, &ret_len) == 0)
                        e->handle_error(e, ret);
        }