From 266686457a36e7e5cdc54b9d271f251ac58774aa Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Fri, 10 Feb 2017 09:10:06 -0800 Subject: [PATCH] [infer][java] Simplify some of the models of Java resources [2/n] Summary: More simplifications of the models Reviewed By: sblackshear Differential Revision: D4541566 fbshipit-source-id: a0d0835 --- .../java/src/java/io/BufferedWriter.java | 19 +-- infer/models/java/src/java/io/FileWriter.java | 35 ----- .../models/java/src/java/io/OutputStream.java | 38 +++--- .../java/src/java/io/OutputStreamWriter.java | 20 +-- .../models/java/src/java/io/PrintWriter.java | 122 +++++++----------- infer/models/java/src/java/io/Writer.java | 13 +- .../java/src/java/net/PlainSocketImpl.java | 76 +++++------ .../java/src/java/net/ServerSocket.java | 25 +--- infer/models/java/src/java/net/Socket.java | 88 ++++--------- infer/tests/build_systems/ant/issues.exp | 2 - infer/tests/build_systems/buck/issues.exp | 2 - .../tests/codetoanalyze/java/infer/issues.exp | 9 -- 12 files changed, 128 insertions(+), 321 deletions(-) delete mode 100644 infer/models/java/src/java/io/FileWriter.java diff --git a/infer/models/java/src/java/io/BufferedWriter.java b/infer/models/java/src/java/io/BufferedWriter.java index 27fab749a..21050f4e8 100644 --- a/infer/models/java/src/java/io/BufferedWriter.java +++ b/infer/models/java/src/java/io/BufferedWriter.java @@ -12,17 +12,7 @@ package java.io; import com.facebook.infer.builtins.InferUndefined; -public class BufferedWriter extends Writer { - - private Writer out; - - public BufferedWriter(Writer out) { - this.out = out; - } - - public BufferedWriter(Writer out, int sz) { - this.out = out; - } +public abstract class BufferedWriter extends Writer { public void flush() throws IOException { InferUndefined.can_throw_ioexception_void(); @@ -52,11 +42,4 @@ public class BufferedWriter extends Writer { InferUndefined.can_throw_ioexception_void(); } - public void close() throws IOException { - if (out instanceof OutputStreamWriter) { - ((OutputStreamWriter) out).close(); - } - } - - } diff --git a/infer/models/java/src/java/io/FileWriter.java b/infer/models/java/src/java/io/FileWriter.java deleted file mode 100644 index f7e1d7d01..000000000 --- a/infer/models/java/src/java/io/FileWriter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package java.io; - -public class FileWriter extends OutputStreamWriter { - - public FileWriter(String fileName) throws IOException { - super(new FileOutputStream(fileName)); - } - - public FileWriter(String fileName, boolean append) throws IOException { - super(new FileOutputStream(fileName, append)); - } - - public FileWriter(File file) throws IOException { - super(new FileOutputStream(file)); - } - - public FileWriter(File file, boolean append) throws IOException { - super(new FileOutputStream(file, append)); - } - - public FileWriter(FileDescriptor fd) { - super(new FileOutputStream(fd)); - } - - -} diff --git a/infer/models/java/src/java/io/OutputStream.java b/infer/models/java/src/java/io/OutputStream.java index 052c6a092..a9907ce10 100644 --- a/infer/models/java/src/java/io/OutputStream.java +++ b/infer/models/java/src/java/io/OutputStream.java @@ -9,31 +9,29 @@ package java.io; +import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; -public abstract class OutputStream implements Closeable { +public class OutputStream { - public void close() throws IOException { - if (this instanceof FileOutputStream) { - ((FileOutputStream) this).close(); - } else if (this instanceof FilterOutputStream) { - ((FilterOutputStream) this).close(); - } - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + } - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } } diff --git a/infer/models/java/src/java/io/OutputStreamWriter.java b/infer/models/java/src/java/io/OutputStreamWriter.java index 80cc90c2b..4b715b812 100644 --- a/infer/models/java/src/java/io/OutputStreamWriter.java +++ b/infer/models/java/src/java/io/OutputStreamWriter.java @@ -9,6 +9,7 @@ package java.io; +import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; import com.facebook.infer.builtins.InferUtils; @@ -17,30 +18,16 @@ import java.nio.charset.CharsetEncoder; public class OutputStreamWriter extends Writer { - private OutputStream out; - public OutputStreamWriter(OutputStream out, String charsetName) throws UnsupportedEncodingException { if (charsetName == null) throw new NullPointerException("charsetName"); else if (InferUtils.isValidCharset(charsetName)) { - this.out = out; + InferBuiltins.__set_file_attribute(this); } else throw new UnsupportedEncodingException(); } - public OutputStreamWriter(OutputStream out) { - this.out = out; - } - - public OutputStreamWriter(OutputStream out, Charset cs) { - this.out = out; - } - - public OutputStreamWriter(OutputStream out, CharsetEncoder enc) { - this.out = out; - } - public void flush() throws IOException { InferUndefined.can_throw_ioexception_void(); } @@ -65,7 +52,4 @@ public class OutputStreamWriter extends Writer { InferUndefined.can_throw_ioexception_void(); } - public void close() throws IOException { - out.close(); - } } diff --git a/infer/models/java/src/java/io/PrintWriter.java b/infer/models/java/src/java/io/PrintWriter.java index 7a78ae5c8..4f19f8cfb 100644 --- a/infer/models/java/src/java/io/PrintWriter.java +++ b/infer/models/java/src/java/io/PrintWriter.java @@ -9,98 +9,66 @@ package java.io; +import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; -public class PrintWriter extends Writer { +public abstract class PrintWriter { - protected Writer out; + OutputStream mOutputStream; - public PrintWriter(OutputStream out) { - this(new OutputStreamWriter(out)); - } - - public PrintWriter(OutputStream out, boolean autoFlush) { - this(new OutputStreamWriter(out), autoFlush); - } - - public PrintWriter(Writer wr) { - out = wr; - } - - public PrintWriter(Writer wr, boolean autoFlush) { - out = wr; - } - - public PrintWriter(File file) throws FileNotFoundException { - this(new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(file)))); - } - - public PrintWriter(File file, String csn) throws FileNotFoundException, - UnsupportedEncodingException { - this(new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(file)))); - } - - public PrintWriter(String fileName) throws FileNotFoundException { - this(new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(fileName)))); - } + public PrintWriter(OutputStream out) { + mOutputStream = out; + } - public PrintWriter(String fileName, String csn) - throws FileNotFoundException, UnsupportedEncodingException { - this(new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(fileName)))); - } + public PrintWriter(OutputStream out, boolean autoFlush) { + mOutputStream = out; + } - public PrintWriter append(char c) throws IOException { - InferUndefined.can_throw_ioexception_void(); - return this; - } + public PrintWriter append(char c) throws IOException { + InferUndefined.can_throw_ioexception_void(); + return this; + } - public PrintWriter append(CharSequence csq) throws IOException { - InferUndefined.can_throw_ioexception_void(); - return this; - } + public PrintWriter append(CharSequence csq) throws IOException { + InferUndefined.can_throw_ioexception_void(); + return this; + } - public PrintWriter append(CharSequence csq, int start, int end) - throws IOException { - InferUndefined.can_throw_ioexception_void(); - return this; - } + public PrintWriter append(CharSequence csq, int start, int end) + throws IOException { + InferUndefined.can_throw_ioexception_void(); + return this; + } - public void close() { - if (out != null) { - try { - if (out instanceof OutputStreamWriter) { - ((OutputStreamWriter) out).close(); - } else if (out instanceof BufferedWriter) { - ((BufferedWriter) out).close(); - } - } catch (IOException x) { - } - } - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(char cbuf[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(char cbuf[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(char cbuf[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(char cbuf[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int c) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int c) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(String str, int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(String str, int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + if (mOutputStream != null) { + mOutputStream.close(); } - + } } diff --git a/infer/models/java/src/java/io/Writer.java b/infer/models/java/src/java/io/Writer.java index 2ddaf3087..897c7d5f5 100644 --- a/infer/models/java/src/java/io/Writer.java +++ b/infer/models/java/src/java/io/Writer.java @@ -11,7 +11,7 @@ package java.io; import com.facebook.infer.builtins.InferUndefined; -public abstract class Writer implements Closeable { +public abstract class Writer { public Writer append(char c) throws IOException { InferUndefined.can_throw_ioexception_void(); @@ -29,16 +29,6 @@ public abstract class Writer implements Closeable { return this; } - public void close() throws IOException { - if (this instanceof OutputStreamWriter) { - ((OutputStreamWriter) this).close(); - } else if (this instanceof BufferedWriter) { - ((BufferedWriter) this).close(); - } else if (this instanceof PrintWriter) { - ((PrintWriter) this).close(); - } - } - public void flush() throws IOException { InferUndefined.can_throw_ioexception_void(); } @@ -63,5 +53,4 @@ public abstract class Writer implements Closeable { InferUndefined.can_throw_ioexception_void(); } - } diff --git a/infer/models/java/src/java/net/PlainSocketImpl.java b/infer/models/java/src/java/net/PlainSocketImpl.java index 224e85189..3208abbbc 100644 --- a/infer/models/java/src/java/net/PlainSocketImpl.java +++ b/infer/models/java/src/java/net/PlainSocketImpl.java @@ -17,56 +17,48 @@ import java.io.InputStream; import java.io.OutputStream; -class PlainSocketImpl extends SocketImpl { +abstract class PlainSocketImpl extends SocketImpl { PlainSocketImpl() { InferBuiltins.__set_file_attribute(this); } - protected void create(boolean stream) throws IOException { InferUndefined.can_throw_ioexception_void(); } - protected void connect(String host, int port) throws IOException { InferUndefined.can_throw_ioexception_void(); } - protected void connect(InetAddress address, int port) throws IOException { InferUndefined.can_throw_ioexception_void(); } - protected void connect(SocketAddress address, int timeout) throws IOException { InferUndefined.can_throw_ioexception_void(); } - protected void bind(InetAddress host, int port) throws IOException { InferUndefined.can_throw_ioexception_void(); } - protected void listen(int backlog) throws IOException { InferUndefined.can_throw_ioexception_void(); } - protected void accept(SocketImpl s) throws IOException { InferUndefined.can_throw_ioexception_void(); } public synchronized InputStream getInputStream() throws IOException { - return new PlainSocketInputStream(this); + return new PlainSocketInputStream(); } public synchronized OutputStream getOutputStream() throws IOException { - return new PlainSocketOutputStream(this); + return new PlainSocketOutputStream(); } - protected int available() throws IOException { return InferUndefined.can_throw_ioexception_int(); } @@ -137,48 +129,48 @@ class PlainSocketImpl extends SocketImpl { InferUndefined.can_throw_ioexception_void(); } - private static class PlainSocketInputStream extends InputStream { - private PlainSocketImpl socketImpl; + private static class PlainSocketInputStream extends InputStream { - public PlainSocketInputStream(PlainSocketImpl socketImpl) { - this.socketImpl = socketImpl; - } + public PlainSocketInputStream() { + InferBuiltins.__set_file_attribute(this); + } - public int available() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int available() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public void close() throws IOException { - socketImpl.close(); - } + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public void close() { + InferBuiltins.__set_mem_attribute(this); } - private static class PlainSocketOutputStream extends OutputStream { - private PlainSocketImpl socketImpl; + } + + private static class PlainSocketOutputStream extends OutputStream { - public PlainSocketOutputStream(PlainSocketImpl socketImpl) { - this.socketImpl = socketImpl; - } + public PlainSocketOutputStream() { + InferBuiltins.__set_file_attribute(this); + } - public void close() throws IOException { - socketImpl.close(); - } + public void write(int oneByte) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int oneByte) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte[] buffer, int offset, int byteCount) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte[] buffer, int offset, int byteCount) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void close() { + InferBuiltins.__set_mem_attribute(this); } + } + } diff --git a/infer/models/java/src/java/net/ServerSocket.java b/infer/models/java/src/java/net/ServerSocket.java index 527fdddde..60810fd11 100644 --- a/infer/models/java/src/java/net/ServerSocket.java +++ b/infer/models/java/src/java/net/ServerSocket.java @@ -15,32 +15,9 @@ import java.io.IOException; public class ServerSocket { - private SocketImpl impl; - - public ServerSocket() throws IOException { - impl = new PlainSocketImpl(); - } - - public ServerSocket(int port) throws IOException { - this(); - } - - public ServerSocket(int port, int backlog) throws IOException { - this(); - } - - public ServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException { - this(); - } - - public void close() throws IOException { - ((PlainSocketImpl) impl).close(); - } - public Socket accept() throws IOException { if (InferUndefined.boolean_undefined()) { - Socket s = new Socket((SocketImpl) null); - return s; + return new Socket(); } else throw new IOException(); } diff --git a/infer/models/java/src/java/net/Socket.java b/infer/models/java/src/java/net/Socket.java index 3de5b170e..4b64afd33 100644 --- a/infer/models/java/src/java/net/Socket.java +++ b/infer/models/java/src/java/net/Socket.java @@ -17,67 +17,31 @@ import com.facebook.infer.builtins.InferBuiltins; public class Socket { - SocketImpl impl; - - public Socket() { - try { - setImpl(); - } catch (IOException e) { - } - } - - void setImpl() throws IOException { - impl = new PlainSocketImpl(); - } - - public Socket(Proxy proxy) { - this(); - } - - protected Socket(SocketImpl impl) throws SocketException { - this(); - } - - public Socket(String host, int port) throws UnknownHostException, - IOException { - this(); - } - - public Socket(InetAddress address, int port) throws IOException { - this(); - } - - public Socket(String host, int port, InetAddress localAddr, int localPort) - throws IOException { - this(); - } - - public Socket(InetAddress address, int port, InetAddress localAddr, - int localPort) throws IOException { - this(); - } - - public Socket(String host, int port, boolean stream) throws IOException { - this(); - } - - public Socket(InetAddress host, int port, boolean stream) - throws IOException { - this(); - } - - public InputStream getInputStream() throws IOException { - InferBuiltins.__check_untainted(this); - return ((PlainSocketImpl) impl).getInputStream(); - } - - public OutputStream getOutputStream() throws IOException { - InferBuiltins.__check_untainted(this); - return ((PlainSocketImpl) impl).getOutputStream(); - } - - public synchronized void close() throws IOException { - ((PlainSocketImpl) impl).close(); - } + InputStream inputStream; + OutputStream outputStream; + + public Socket() { + InferBuiltins.__set_file_attribute(this); + inputStream = new InputStream(); + InferBuiltins.__set_file_attribute(inputStream); + outputStream = new OutputStream(); + InferBuiltins.__set_file_attribute(outputStream); + } + + public InputStream getInputStream() throws IOException { + InferBuiltins.__check_untainted(this); + return inputStream; + } + + public OutputStream getOutputStream() throws IOException { + InferBuiltins.__check_untainted(this); + return outputStream; + } + + public void close() { + InferBuiltins.__set_mem_attribute(this); + InferBuiltins.__set_mem_attribute(inputStream); + InferBuiltins.__set_mem_attribute(outputStream); + } } diff --git a/infer/tests/build_systems/ant/issues.exp b/infer/tests/build_systems/ant/issues.exp index c22d86fad..2e1534aec 100644 --- a/infer/tests/build_systems/ant/issues.exp +++ b/infer/tests/build_systems/ant/issues.exp @@ -168,13 +168,11 @@ codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.socketNotClosed( codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.themeObtainTypedArrayAndLeak(Resources$Theme), 2, RESOURCE_LEAK, [start of procedure themeObtainTypedArrayAndLeak(...),start of procedure ignore(...),return from a call to void ResourceLeaks.ignore(Object)] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResources(), 11, RESOURCE_LEAK, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResourcesRandomAccessFile(), 10, RESOURCE_LEAK, [start of procedure twoResourcesRandomAccessFile(),Taking true branch,exception java.io.IOException] -codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResourcesServerSocket(), 10, RESOURCE_LEAK, [start of procedure twoResourcesServerSocket(),Taking true branch,exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.zipFileLeakExceptionalBranch(), 5, RESOURCE_LEAK, [start of procedure zipFileLeakExceptionalBranch(),exception java.io.IOException,Switch condition is true. Entering switch case] codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketIgnoreExceptionNoVerify(SSLSocketFactory), 9, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure socketIgnoreExceptionNoVerify(...),start of procedure throwExceptionIfNoVerify(...),Taking true branch,exception javax.net.ssl.SSLException,return from a call to void TaintExample.throwExceptionIfNoVerify(SSLSocket,String),Switch condition is true. Entering switch case] codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketNotVerifiedSimple(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure socketNotVerifiedSimple(...)] codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketVerifiedForgotToCheckRetval(SSLSocketFactory,HostnameVerifier,SSLSession), 7, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure socketVerifiedForgotToCheckRetval(...)] codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference1(SSLSocketFactory), 4, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure taintingShouldNotPreventInference1(...),start of procedure socketNotVerifiedSimple(...),return from a call to InputStream TaintExample.socketNotVerifiedSimple(SSLSocketFactory)] -codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference2(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure taintingShouldNotPreventInference2(...),start of procedure callReadInputStreamCauseTaintError(...),start of procedure readInputStream(...),return from a call to InputStream TaintExample.readInputStream(Socket),return from a call to Socket TaintExample.callReadInputStreamCauseTaintError(SSLSocketFactory)] codetoanalyze/java/infer/TaintExample.java, Socket TaintExample.callReadInputStreamCauseTaintError(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure callReadInputStreamCauseTaintError(...)] codetoanalyze/java/infer/TaintExample.java, void TaintExample.contentValuesPutWithTaintedString(ContentValues,SharedPreferences,String,String), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure contentValuesPutWithTaintedString(...)] codetoanalyze/java/infer/TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethods1(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure interprocTaintErrorWithModelMethods1(),start of procedure returnTaintedSourceModelMethods(),return from a call to Object TaintExample.returnTaintedSourceModelMethods()] diff --git a/infer/tests/build_systems/buck/issues.exp b/infer/tests/build_systems/buck/issues.exp index 7d2903b92..eeb97dc08 100644 --- a/infer/tests/build_systems/buck/issues.exp +++ b/infer/tests/build_systems/buck/issues.exp @@ -168,13 +168,11 @@ infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.sock infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.themeObtainTypedArrayAndLeak(Resources$Theme), 2, RESOURCE_LEAK, [start of procedure themeObtainTypedArrayAndLeak(...),start of procedure ignore(...),return from a call to void ResourceLeaks.ignore(Object)] infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResources(), 11, RESOURCE_LEAK, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResourcesRandomAccessFile(), 10, RESOURCE_LEAK, [start of procedure twoResourcesRandomAccessFile(),Taking true branch,exception java.io.IOException] -infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResourcesServerSocket(), 10, RESOURCE_LEAK, [start of procedure twoResourcesServerSocket(),Taking true branch,exception java.io.IOException] infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.zipFileLeakExceptionalBranch(), 5, RESOURCE_LEAK, [start of procedure zipFileLeakExceptionalBranch(),exception java.io.IOException,Switch condition is true. Entering switch case] infer/tests/codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketIgnoreExceptionNoVerify(SSLSocketFactory), 9, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure socketIgnoreExceptionNoVerify(...),start of procedure throwExceptionIfNoVerify(...),Taking true branch,exception javax.net.ssl.SSLException,return from a call to void TaintExample.throwExceptionIfNoVerify(SSLSocket,String),Switch condition is true. Entering switch case] infer/tests/codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketNotVerifiedSimple(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure socketNotVerifiedSimple(...)] infer/tests/codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketVerifiedForgotToCheckRetval(SSLSocketFactory,HostnameVerifier,SSLSession), 7, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure socketVerifiedForgotToCheckRetval(...)] infer/tests/codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference1(SSLSocketFactory), 4, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure taintingShouldNotPreventInference1(...),start of procedure socketNotVerifiedSimple(...),return from a call to InputStream TaintExample.socketNotVerifiedSimple(SSLSocketFactory)] -infer/tests/codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference2(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure taintingShouldNotPreventInference2(...),start of procedure callReadInputStreamCauseTaintError(...),start of procedure readInputStream(...),return from a call to InputStream TaintExample.readInputStream(Socket),return from a call to Socket TaintExample.callReadInputStreamCauseTaintError(SSLSocketFactory)] infer/tests/codetoanalyze/java/infer/TaintExample.java, Socket TaintExample.callReadInputStreamCauseTaintError(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure callReadInputStreamCauseTaintError(...)] infer/tests/codetoanalyze/java/infer/TaintExample.java, void TaintExample.contentValuesPutWithTaintedString(ContentValues,SharedPreferences,String,String), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure contentValuesPutWithTaintedString(...)] infer/tests/codetoanalyze/java/infer/TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethods1(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure interprocTaintErrorWithModelMethods1(),start of procedure returnTaintedSourceModelMethods(),return from a call to Object TaintExample.returnTaintedSourceModelMethods()] diff --git a/infer/tests/codetoanalyze/java/infer/issues.exp b/infer/tests/codetoanalyze/java/infer/issues.exp index e16fadf16..67ab7c688 100644 --- a/infer/tests/codetoanalyze/java/infer/issues.exp +++ b/infer/tests/codetoanalyze/java/infer/issues.exp @@ -277,9 +277,6 @@ codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.socketNotClosed( codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.themeObtainTypedArrayAndLeak(Resources$Theme), 2, RESOURCE_LEAK, [start of procedure themeObtainTypedArrayAndLeak(...),start of procedure ignore(...),return from a call to void ResourceLeaks.ignore(Object)] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResources(), 11, RESOURCE_LEAK, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResourcesRandomAccessFile(), 10, RESOURCE_LEAK, [start of procedure twoResourcesRandomAccessFile(),Taking true branch,exception java.io.IOException] -codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResourcesServerSocket(), 7, NULL_TEST_AFTER_DEREFERENCE, [start of procedure twoResourcesServerSocket(),Taking false branch] -codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResourcesServerSocket(), 8, NULL_TEST_AFTER_DEREFERENCE, [start of procedure twoResourcesServerSocket(),Taking true branch,Taking false branch] -codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.twoResourcesServerSocket(), 10, RESOURCE_LEAK, [start of procedure twoResourcesServerSocket(),Taking true branch,exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.zipFileLeakExceptionalBranch(), 5, RESOURCE_LEAK, [start of procedure zipFileLeakExceptionalBranch(),exception java.io.IOException,Switch condition is true. Entering switch case] codetoanalyze/java/infer/ReturnValueIgnored.java, void ReturnValueIgnored.returnValueIgnored(), 1, RETURN_VALUE_IGNORED, [start of procedure returnValueIgnored()] codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketIgnoreExceptionNoVerify(SSLSocketFactory), 9, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure socketIgnoreExceptionNoVerify(...),start of procedure throwExceptionIfNoVerify(...),Taking true branch,exception javax.net.ssl.SSLException,return from a call to void TaintExample.throwExceptionIfNoVerify(SSLSocket,String),Switch condition is true. Entering switch case] @@ -287,7 +284,6 @@ codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketNotVe codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketVerifiedForgotToCheckRetval(SSLSocketFactory,HostnameVerifier,SSLSession), 6, RETURN_VALUE_IGNORED, [start of procedure socketVerifiedForgotToCheckRetval(...)] codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.socketVerifiedForgotToCheckRetval(SSLSocketFactory,HostnameVerifier,SSLSession), 7, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure socketVerifiedForgotToCheckRetval(...)] codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference1(SSLSocketFactory), 4, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure taintingShouldNotPreventInference1(...),start of procedure socketNotVerifiedSimple(...),return from a call to InputStream TaintExample.socketNotVerifiedSimple(SSLSocketFactory)] -codetoanalyze/java/infer/TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference2(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure taintingShouldNotPreventInference2(...),start of procedure callReadInputStreamCauseTaintError(...),start of procedure readInputStream(...),return from a call to InputStream TaintExample.readInputStream(Socket),return from a call to Socket TaintExample.callReadInputStreamCauseTaintError(SSLSocketFactory)] codetoanalyze/java/infer/TaintExample.java, Socket TaintExample.callReadInputStreamCauseTaintError(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure callReadInputStreamCauseTaintError(...)] codetoanalyze/java/infer/TaintExample.java, void TaintExample.contentValuesPutWithTaintedString(ContentValues,SharedPreferences,String,String), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure contentValuesPutWithTaintedString(...)] codetoanalyze/java/infer/TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethods1(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure interprocTaintErrorWithModelMethods1(),start of procedure returnTaintedSourceModelMethods(),return from a call to Object TaintExample.returnTaintedSourceModelMethods()] @@ -308,15 +304,10 @@ codetoanalyze/java/infer/TaintExample.java, void TaintExample.testPrivacySourceA codetoanalyze/java/infer/TaintExample.java, void TaintExample.testPrivacySourceFieldAnnotPropagation(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure testPrivacySourceFieldAnnotPropagation()] codetoanalyze/java/infer/TaintExample.java, void TaintExample.testPrivacySourceInstanceFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure testPrivacySourceInstanceFieldAnnot()] codetoanalyze/java/infer/TaintExample.java, void TaintExample.testPrivacySourceStaticFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure testPrivacySourceStaticFieldAnnot()] -codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.bufferedWriterClosed(), 8, NULL_TEST_AFTER_DEREFERENCE, [start of procedure bufferedWriterClosed(),exception java.io.IOException,Switch condition is true. Entering switch case,Taking false branch] codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.bufferedWriterNotClosedAfterWrite(), 7, RESOURCE_LEAK, [start of procedure bufferedWriterNotClosedAfterWrite(),exception java.io.IOException] -codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.fileWriterClosed(), 7, NULL_TEST_AFTER_DEREFERENCE, [start of procedure fileWriterClosed(),exception java.io.IOException,Switch condition is true. Entering switch case,Taking false branch] codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.fileWriterNotClosedAfterWrite(), 6, RESOURCE_LEAK, [start of procedure fileWriterNotClosedAfterWrite(),exception java.io.IOException] -codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.outputStreamWriterClosed(), 7, NULL_TEST_AFTER_DEREFERENCE, [start of procedure outputStreamWriterClosed(),exception java.io.IOException,Switch condition is true. Entering switch case,Taking false branch] codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.outputStreamWriterNotClosedAfterWrite(), 6, RESOURCE_LEAK, [start of procedure outputStreamWriterNotClosedAfterWrite(),exception java.io.IOException] codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.pipedWriterNotClosedAfterConnect(PipedReader), 7, RESOURCE_LEAK, [start of procedure pipedWriterNotClosedAfterConnect(...),exception java.io.IOException] codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.pipedWriterNotClosedAfterConstructedWithReader(), 8, RESOURCE_LEAK, [start of procedure pipedWriterNotClosedAfterConstructedWithReader(),exception java.io.IOException] -codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.printWriterClosed(), 7, NULL_TEST_AFTER_DEREFERENCE, [start of procedure printWriterClosed(),exception java.io.IOException,Switch condition is true. Entering switch case,Taking false branch] codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.printWriterNotClosedAfterAppend(), 4, RESOURCE_LEAK, [start of procedure printWriterNotClosedAfterAppend()] -codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.writerClosed(), 7, NULL_TEST_AFTER_DEREFERENCE, [start of procedure writerClosed(),exception java.io.IOException,Switch condition is true. Entering switch case,Taking false branch] codetoanalyze/java/infer/WriterLeaks.java, void WriterLeaks.writerNotClosedAfterWrite(), 6, RESOURCE_LEAK, [start of procedure writerNotClosedAfterWrite(),exception java.io.IOException]