Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Wiki MarkupThe contracts of the read methods for {{InputStream}} and {{Reader}} classes and their subclasses are complicated with regard to filling byte or character arrays. According to the Java API \ [[API 2006|AA. References#API 06]\] for the class {{InputStream}}, the {{read(byte\[\] b, int off, int len)}} method provides the following behavior:

The default implementation of this method blocks until the requested amount of input data len has been read, end of file is detected, or an exception is thrown. Subclasses are encouraged to provide a more efficient implementation of this method.

Wiki MarkupHowever, the {{read(byte\[\])}} method:

reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. The number of bytes read is, at most, equal to the length of b.

...

MITRE CWE

CWE-135. Incorrect calculation of multi-byte string length

Bibliography

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f826b200-1df0-4fee-a5c1-61e0398d6aed"><ac:plain-text-body><! [CDATA[ [[API 2006AA. References#API 06]]

Class InputStream, DataInputStream]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9a6b78d5-505a-4fed-89db-855f66085a5d"><ac:plain-text-body><!

[CDATA[ [[Chess 2007AA. References#Chess 07] ]

8.1, Handling Errors with Return Codes ]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="79a70978-f101-4f0a-a01e-a0d424027140"><ac:plain-text-body><![CDATA[

[ [Harold 1999AA. References#Harold 99] ]

Chapter 7, Data Streams, Reading Byte Arrays ]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e082ce86-2a94-414f-ac0f-e9494beae788"><ac:plain-text-body><![CDATA [ [[Phillips 2005AA. References#Phillips 05] ]

 ]]></ac:plain-text-body></ac:structured-macro>

...

      12. Input Output (FIO)      FIO11-J. Do not attempt to read raw binary data as character data