github.com/vc42/parquet-go@v0.0.0-20240320194221-1a9adb5f23f5/encoding/plain/plain_purego.go (about)

     1  //go:build purego || !amd64
     2  
     3  package plain
     4  
     5  func validateByteArray(b []byte) status {
     6  	for i := 0; i < len(b); {
     7  		r := len(b) - i
     8  		if r < ByteArrayLengthSize {
     9  			return errTooShort
    10  		}
    11  		n := ByteArrayLength(b[i:])
    12  		i += ByteArrayLengthSize
    13  		r -= ByteArrayLengthSize
    14  		if n > r {
    15  			return errTooShort
    16  		}
    17  		if n > MaxByteArrayLength {
    18  			return errTooLarge
    19  		}
    20  		i += n
    21  	}
    22  	return ok
    23  }