(max int)
| 238 | } |
| 239 | |
| 240 | func (player *Player) ReadNStringLimited(max int) (s string, read int, err error) { |
| 241 | max = (max * 4) + 3 |
| 242 | |
| 243 | length, err := player.ReadVarInt() |
| 244 | buff := make([]byte, 8) |
| 245 | read = binary.PutUvarint(buff, uint64(length)) |
| 246 | if err != nil { |
| 247 | return "", read, err |
| 248 | } |
| 249 | if length > max { |
| 250 | player.Kick("Invalid packet") |
| 251 | return "", read, nil |
| 252 | } |
| 253 | buffer := make([]byte, length) |
| 254 | _, err = io.ReadFull(player.io.rdr, buffer) |
| 255 | if err != nil { |
| 256 | return "", read + length, err |
| 257 | } |
| 258 | return string(buffer), read + length, nil |
| 259 | } |
| 260 | |
| 261 | func (player *Player) WriteByteArray(data []byte) (err error) { |
| 262 | _, err = player.io.wtr.Write(data) |
no test coverage detected