...
Code Block | ||
---|---|---|
| ||
class StreamGobbler extends Thread { InputStream is; PrintStream os; StreamGobbler(InputStream is, PrintStream os) { this.is = is; this.os = os; } public void run() { try { int c; while ((c = is.read()) != -1) os.print((char) c); } catch (IOException x) { // handle error } } } public class Exec { public static void main(String[] args) throws IOException, InterruptedException { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("notemaker"); // Any error message? StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), System.err); // Any output? StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), System.out); errorGobbler.start(); outputGobbler.start(); // Any error? int exitVal = proc.waitFor(); errorGobbler.join(); // Handle condition where the outputGobbler.join(); // process ends before the threads finish } } |
Exceptions
FIO10FIO07-EX0: Failure to supply input to a process that never reads input from its input stream is harmless, and can be beneficial. Failure to empty the output or error streams of a process that never sends output to its output or error streams is similarly harmless, or even beneficial. Consequently, programs are permitted to ignore the input, output, or error streams when, and only when, the process is guaranteed those streams.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
FIO10 FIO07-J | low | probable | medium | P4 | L3 |
Related Vulnerabilities
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8cfa5ed6f1dc29de-a4654d85-4e064f00-b7818573-a8c578b24500ed2a51385586"><ac:plain-text-body><![CDATA[ | [[API 06 | AA. Bibliography#API 06]] | method [exec() | http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#exec(java.lang.String)] | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c67a714399559116-e57c422d-4d1848f6-8f7d8c3a-abacf155396e65811a037c34"><ac:plain-text-body><![CDATA[ | [[Daconta 00 | AA. Bibliography#Daconta 00]] |
| ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="62a3b451bfc06373-f72c0c67-4a5947bb-873785a1-0d0d5c9421a85828b8f11c17"><ac:plain-text-body><![CDATA[ | [[Daconta 03 | AA. Bibliography#Daconta 03]] | Pitfall 1 | ]]></ac:plain-text-body></ac:structured-macro> |
...