From 9d4f5b3cabb2a3535fe72d395bb6319cf2a1ae13 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Mon, 15 May 2023 10:13:01 +0200 Subject: [PATCH] End the connection when reading a wrong message length. --- src/context.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/context.zig b/src/context.zig index 1aa643a..576d9fc 100644 --- a/src/context.zig +++ b/src/context.zig @@ -451,8 +451,15 @@ pub const Context = struct { try self.close(i); return Event.init(Event.Type.DISCONNECTION, i, fd.fd, null); }, + error.wrongMessageLength => { + log.warn("wrong message length, terminating the connection", .{}); + try self.close(i); + return Event.init(Event.Type.DISCONNECTION, i, fd.fd, null); + }, else => { - return err; + log.warn("unmanaged error while reading a message ({})", .{err}); + try self.close(i); + return Event.init(Event.Type.ERROR, i, fd.fd, null); }, };