1
0
Fork 0
mirror of https://github.com/fluffle/goirc synced 2025-09-06 00:43:20 +00:00

handlers: check array bounds before indexing

This commit is contained in:
John Soros 2015-11-29 04:28:05 +01:00
parent 1e190eb233
commit f0ae9bb509
3 changed files with 48 additions and 2 deletions

View file

@ -3,6 +3,8 @@ package client
import (
"strings"
"time"
"runtime"
"github.com/fluffle/goirc/logging"
)
// We parse an incoming line into this struct. Line.Cmd is used as the trigger
@ -156,3 +158,14 @@ func ParseLine(s string) *Line {
}
return line
}
func (line *Line) argslen(minlen int) bool {
pc, _, _, _ := runtime.Caller(1)
fn := runtime.FuncForPC(pc)
if len(line.Args) <= minlen {
logging.Warn("%s: too few arguments: %s", fn.Name(), strings.Join(line.Args, " "))
return false
}
return true
}