@@ -351,10 +351,13 @@ @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; + if (length > UINT64_MAX) + @throw [OFOutOfRangeException exception]; + if ((uint64_t)length > _toRead) length = (size_t)_toRead; ret = [_stream readIntoBuffer: buffer length: length];