Fixed two issues in BytesInputStream.read

The check to determine if all bytes were read used the wrong length
variable (local instead of field). This caused the stream to never
report eof and some stream operations would never terminate.

The check to prevent reading more bytes than available also used the
wrong lenght variable (local instead of field). This caused an
ArrayIndexOutOfBoudsException in System.arrayCopy().