[PATCH] ubusd: fix disconnection when sending invalid fd

adrian.frances at netduma.com adrian.frances at netduma.com
Tue Aug 17 05:04:51 PDT 2021


From: Adrian Frances <adrian.frances at netduma.com>

According to man 7 unix, sendmsg returns EBADF when sending an
invalid file descriptor as ancillary data. The patch avois ubus
disconnecting the client when EBADF is received for the mentioned
case.

Signed-off-by: Adrian Frances <adrian.frances at netduma.com>
---
 ubusd_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ubusd_main.c b/ubusd_main.c
index d454b1a..8a043b7 100644
--- a/ubusd_main.c
+++ b/ubusd_main.c
@@ -67,6 +67,12 @@ static void client_cb(struct uloop_fd *sock, unsigned int events)
 			case EINTR:
 			case EAGAIN:
 				break;
+			case EBADF:
+				if(fcntl(sock->fd, F_GETFD) != -1) {
+					cl->txq_ofs = 0;
+					ubus_msg_dequeue(cl);
+					continue;
+				}
 			default:
 				goto disconnect;
 			}
-- 
2.25.1




More information about the openwrt-devel mailing list