Enforce reader.read(length) <= bufferLength.

Otherwise, you’ll be waiting for a long, long time.