From 36ad3a780fd5cbb7931f6380e069a5538ed813e1 Mon Sep 17 00:00:00 2001 From: Yannick Dylla <17772145+ydylla@users.noreply.github.com> Date: Tue, 16 Jul 2024 22:22:26 +0200 Subject: [PATCH] fix: ssh & xmpp not reporting ErrConsumedAllPrefetchedBytes errors --- modules/l4ssh/matcher.go | 6 +++--- modules/l4xmpp/matcher.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/l4ssh/matcher.go b/modules/l4ssh/matcher.go index af8aa07..931e252 100644 --- a/modules/l4ssh/matcher.go +++ b/modules/l4ssh/matcher.go @@ -40,9 +40,9 @@ func (MatchSSH) CaddyModule() caddy.ModuleInfo { // Match returns true if the connection looks like SSH. func (m MatchSSH) Match(cx *layer4.Connection) (bool, error) { p := make([]byte, len(sshPrefix)) - n, err := io.ReadFull(cx, p) - if err != nil || n < len(sshPrefix) { - return false, nil + _, err := io.ReadFull(cx, p) + if err != nil { + return false, err } return bytes.Equal(p, sshPrefix), nil } diff --git a/modules/l4xmpp/matcher.go b/modules/l4xmpp/matcher.go index b9a2d45..a244583 100644 --- a/modules/l4xmpp/matcher.go +++ b/modules/l4xmpp/matcher.go @@ -40,15 +40,15 @@ func (MatchXMPP) CaddyModule() caddy.ModuleInfo { // Match returns true if the connection looks like XMPP. func (m MatchXMPP) Match(cx *layer4.Connection) (bool, error) { p := make([]byte, minXmppLength) - n, err := io.ReadFull(cx, p) - if err != nil || n < minXmppLength { // needs at least 50 (fix for adium/pidgin) - return false, nil + _, err := io.ReadFull(cx, p) + if err != nil { + return false, err } return strings.Contains(string(p), xmppWord), nil } var xmppWord = "jabber" -var minXmppLength = 50 +var minXmppLength = 50 // needs at least 50 (fix for adium/pidgin) // Interface guard var _ layer4.ConnMatcher = (*MatchXMPP)(nil)