MCPcopy Create free account
hub / github.com/TyphoonMC/TyphoonCore / ReadStringLimited

Method ReadStringLimited

utils.go:221–238  ·  view source on GitHub ↗
(max int)

Source from the content-addressed store, hash-verified

219}
220
221func (player *Player) ReadStringLimited(max int) (s string, err error) {
222 max = (max * 4) + 3
223
224 length, err := player.ReadVarInt()
225 if err != nil {
226 return "", err
227 }
228 if length > max {
229 player.Kick("Invalid packet")
230 return "", nil
231 }
232 buffer := make([]byte, length)
233 _, err = io.ReadFull(player.io.rdr, buffer)
234 if err != nil {
235 return "", err
236 }
237 return string(buffer), nil
238}
239
240func (player *Player) ReadNStringLimited(max int) (s string, read int, err error) {
241 max = (max * 4) + 3

Callers 4

ReadMethod · 0.80
ReadMethod · 0.80
ReadMethod · 0.80
ReadMethod · 0.80

Calls 2

ReadVarIntMethod · 0.95
KickMethod · 0.95

Tested by

no test coverage detected