mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-07-03 04:04:34 +02:00
Reject some evil strings.
This commit is contained in:
parent
da10a5d2b8
commit
cfbd2824e6
12
client.go
12
client.go
@ -134,7 +134,7 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
if c.IsSilenced() {
|
if c.IsSilenced() {
|
||||||
c.Msg <- fmt.Sprintf("-> Message rejected, silenced.")
|
c.Msg <- fmt.Sprintf("-> Message rejected, silenced.")
|
||||||
} else {
|
} else {
|
||||||
c.Server.Broadcast(msg, nil)
|
c.Server.Broadcast(msg[:200], nil)
|
||||||
}
|
}
|
||||||
case "/nick":
|
case "/nick":
|
||||||
if len(parts) == 2 {
|
if len(parts) == 2 {
|
||||||
@ -146,7 +146,11 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
if len(parts) == 2 {
|
if len(parts) == 2 {
|
||||||
client := c.Server.Who(parts[1])
|
client := c.Server.Who(parts[1])
|
||||||
if client != nil {
|
if client != nil {
|
||||||
c.Msg <- fmt.Sprintf("-> %s is %s via %s", client.Name, client.Fingerprint(), client.Conn.ClientVersion())
|
version := client.Conn.ClientVersion()
|
||||||
|
if len(version) > 100 {
|
||||||
|
version = []byte("Evil Jerk with a superlong string")
|
||||||
|
}
|
||||||
|
c.Msg <- fmt.Sprintf("-> %s is %s via %s", client.Name, client.Fingerprint(), version)
|
||||||
} else {
|
} else {
|
||||||
c.Msg <- fmt.Sprintf("-> No such name: %s", parts[1])
|
c.Msg <- fmt.Sprintf("-> No such name: %s", parts[1])
|
||||||
}
|
}
|
||||||
@ -216,8 +220,8 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg := fmt.Sprintf("%s: %s", c.Name, line)
|
msg := fmt.Sprintf("%s: %s", c.Name, line)
|
||||||
if c.IsSilenced() {
|
if c.IsSilenced() || len(msg) > 1000 {
|
||||||
c.Msg <- fmt.Sprintf("-> Message rejected, silenced.")
|
c.Msg <- fmt.Sprintf("-> Message rejected.")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.Server.Broadcast(msg, c)
|
c.Server.Broadcast(msg, c)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user