Versions Compared

Key

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

The write() method, defined in the class java.io.OutputStream, takes an argument of type int the value of which must be in the range 0 to 255. Because a value of type int could be outside this range, failure to range check can result in the truncation of the higher-order bits of the argument.

Wiki MarkupThe general contract for the {{write()}} method says that it writes one byte to the output stream. The byte to be written constitutes the eight lower-order bits of the argument {{b}}, passed to the {{write()}} method; the 24 high-order bits of {{b}} are ignored (see \ [[API 2006|AA. References#API 06]\] [{{java.io.OutputStream.write()}}|http://download.oracle.com/javase/6/docs/api/java/io/OutputStream.html#write(int)] for more information).

Noncompliant Code Example

...

MITRE CWE

CWE-252. Unchecked return value

Bibliography

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="641d93ac-8fc3-4b9d-b86c-94394fc18a96"><ac:plain-text-body><![CDATA [ [[API 2006AA. References#API 06]]

[Method write()

http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html#write(int)]

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c8a3e4d9-bd53-46ff-b52a-f903fe983281"><ac:plain-text-body><! [CDATA[ [[Harold 1999AA. References#Harold 99]]

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

...

FIO08-J. Use an int to capture the return value of methods that read a character or byte      12. Input Output (FIO)