From 1cb613ee4b87d95efab8f5e73459d97f62afa271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 31 May 2021 20:33:34 +0200 Subject: [PATCH] pulse-server: terminate connection in more cases If any of those two branches are taken, the connection cannot make forward progress since no data will be read/sent from/to the client. For example, sending just 21 invalid bytes to the server causes the first 20 bytes (client descriptor) to be read, then rejected, leaving `client->message == NULL`. But since polling is level triggered, `on_client_data()` and thus `do_read()` will continue to be called ceaselessly, thereby spamming the log and wasting resources. --- src/modules/module-protocol-pulse/pulse-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 08bde2e2e..4c896ceee 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -5523,7 +5523,7 @@ static int do_read(struct client *client) uint32_t idx = client->in_index - sizeof(client->desc); if (client->message == NULL) { - res = -EIO; + res = -EPROTO; goto exit; } data = SPA_PTROFF(client->message->data, idx, void); @@ -5551,7 +5551,7 @@ static int do_read(struct client *client) flags = ntohl(client->desc.flags); if ((flags & FLAG_SHMMASK) != 0) { - res = -ENOTSUP; + res = -EPROTO; goto exit; }