From d98d2dfc529b6cdec18601823f81582bbcb805f4 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 29 Jun 2017 15:17:15 +0300 Subject: [PATCH] fix error path in security handler Signed-off-by: Vasiliy Tolstov --- handlers.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/handlers.go b/handlers.go index 960f9b7..2808fc1 100644 --- a/handlers.go +++ b/handlers.go @@ -205,16 +205,14 @@ func (*DefaultServerSecurityHandler) Handle(c Conn) error { if authErr != nil { authCode = uint32(1) } - if err := binary.Write(c, binary.BigEndian, authCode); err != nil { return err } if err := c.Flush(); err != nil { return err } - if authErr != nil { - if err := binary.Write(c, binary.BigEndian, len(authErr.Error())); err != nil { + if err := binary.Write(c, binary.BigEndian, uint32(len(authErr.Error()))); err != nil { return err } if err := binary.Write(c, binary.BigEndian, []byte(authErr.Error())); err != nil { @@ -225,14 +223,13 @@ func (*DefaultServerSecurityHandler) Handle(c Conn) error { } return authErr } - return nil } type DefaultClientServerInitHandler struct{} func (*DefaultClientServerInitHandler) Handle(c Conn) error { - srvInit := &ServerInit{} + srvInit := ServerInit{} if err := binary.Read(c, binary.BigEndian, &srvInit.FBWidth); err != nil { return err @@ -258,7 +255,6 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error { c.SetHeight(srvInit.FBHeight) c.SetPixelFormat(&srvInit.PixelFormat) - fmt.Printf("%s\n", srvInit) if c.Protocol() == "aten" { ikvm := struct { _ [8]byte