models/msg: limit single package length

This commit is contained in:
fatedier 2016-08-07 13:18:54 +08:00
parent 3b06d771ac
commit 1da81ad7d3

View File

@ -146,6 +146,11 @@ func pipeDecrypt(r *conn.Conn, w *conn.Conn, conf config.BaseConf, needRecord bo
} }
cnt, res, left = unpkgMsg(newBuf) cnt, res, left = unpkgMsg(newBuf)
if cnt < 0 { if cnt < 0 {
// limit one package length, maximum is 1MB
if len(res) > 1024*1024 {
log.Warn("ProxyName [%s], package length exceeds the limit")
return fmt.Errorf("package length error")
}
continue continue
} }