Add vanilla parity harness and harden server boundaries

This commit is contained in:
Daniar Mannanov 2026-08-10 22:52:44 +03:00
parent 1924cb5591
commit ca019756ec
25 changed files with 1118 additions and 217 deletions

View file

@ -5,6 +5,7 @@ import (
"errors"
"io"
"math"
"unicode/utf8"
)
// ErrShortBuffer is returned when a read would exceed the buffer's contents.
@ -119,6 +120,12 @@ func (r *Reader) String() (string, error) {
if err != nil {
return "", err
}
if !utf8.Valid(b) {
return "", ErrInvalidString
}
if utf8.RuneCount(b) > MaxStringLen {
return "", ErrStringTooLong
}
return string(b), nil
}