diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-05 12:31:35 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-05 12:31:35 +0200 |
commit | 4d909fffd88c2a66094cfec6f43ac932113906b9 (patch) | |
tree | b160bbb784b53521e4bef32402a50996faaca6bb | |
parent | ad8461491b35c739683971deff32a3203d0d7e5d (diff) | |
download | easybridge-4d909fffd88c2a66094cfec6f43ac932113906b9.tar.gz easybridge-4d909fffd88c2a66094cfec6f43ac932113906b9.zip |
Fix out of bounds error in user commands (the most stupid bug possible)
-rw-r--r-- | server.go | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -225,6 +225,10 @@ func handleTxnEvent(e *mxlib.Event) error { func handleSystemMessage(mxid string, msg string) { cmd := strings.Fields(msg) + if len(cmd) == 0 { + return + } + switch cmd[0] { case "help": ezbrSystemSend(mxid, "Welcome to Easybridge! Here is a list of available commands:") @@ -246,6 +250,11 @@ func handleSystemMessage(mxid string, msg string) { ezbrSystemSendf(mxid, "No account currently configured") } case "join": + if len(cmd) != 2 { + ezbrSystemSendf(mxid, "Usage: %s <protocol or account> <room id>", cmd[0]) + return + } + account := findAccount(mxid, cmd[1]) if account != nil { err := account.Conn.Join(connector.RoomID(cmd[2])) @@ -256,6 +265,11 @@ func handleSystemMessage(mxid string, msg string) { ezbrSystemSendf(mxid, "No account with name or using protocol %s", cmd[1]) } case "query", "talk": + if len(cmd) != 2 { + ezbrSystemSendf(mxid, "Usage: %s <protocol or account> <user id>", cmd[0]) + return + } + account := findAccount(mxid, cmd[1]) if account != nil { quser := connector.UserID(cmd[2]) @@ -278,6 +292,11 @@ func handleSystemMessage(mxid string, msg string) { ezbrSystemSendf(mxid, "No account with name or using protocol %s", cmd[1]) } case "search": + if len(cmd) < 2 { + ezbrSystemSendf(mxid, "Usage: %s <protocol or account> <name>", cmd[0]) + return + } + account := findAccount(mxid, cmd[1]) if account != nil { rep, err := account.Conn.SearchForUsers(strings.Join(cmd[2:], " ")) |