From 301a69ec3bb1376c280110c8a9cb7bfca2828ee1 Mon Sep 17 00:00:00 2001 From: Georg Reinke Date: Sun, 13 Feb 2022 10:53:30 +0100 Subject: [PATCH] auth: handle improperly formatted OK correctly Propely wait for REJECT after sending the cancel - without this, we could actually get a panic if the bus sends an OK without a GUID. --- auth.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/auth.go b/auth.go index a59b4c0..0f3b252 100644 --- a/auth.go +++ b/auth.go @@ -176,9 +176,10 @@ func (conn *Conn) tryAuth(m Auth, state authState, in *bufio.Reader) (error, boo return err, false } state = waitingForReject + } else { + conn.uuid = string(s[1]) + return nil, true } - conn.uuid = string(s[1]) - return nil, true case state == waitingForData: err = authWriteLine(conn.transport, []byte("ERROR")) if err != nil { @@ -191,9 +192,10 @@ func (conn *Conn) tryAuth(m Auth, state authState, in *bufio.Reader) (error, boo return err, false } state = waitingForReject + } else { + conn.uuid = string(s[1]) + return nil, true } - conn.uuid = string(s[1]) - return nil, true case state == waitingForOk && string(s[0]) == "DATA": err = authWriteLine(conn.transport, []byte("DATA")) if err != nil {