Reviewed By: jeremydubreil Differential Revision: D2665885 fb-gh-sync-id: 4f821efmaster
parent
761e4acc08
commit
8e9ed5eb6b
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - 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 javax.net;
|
||||||
|
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
import com.facebook.infer.models.InferBuiltins;
|
||||||
|
|
||||||
|
public class SocketFactory {
|
||||||
|
|
||||||
|
// using recency abstraction to remember the last Socket created
|
||||||
|
private static Socket sLast;
|
||||||
|
|
||||||
|
public static Socket getLastSocket() {
|
||||||
|
return sLast;
|
||||||
|
}
|
||||||
|
|
||||||
|
// proxy for Socket of undefined type
|
||||||
|
private native Socket genSocket();
|
||||||
|
|
||||||
|
private Socket returnAllocatedSocket() {
|
||||||
|
Socket socket = genSocket();
|
||||||
|
InferBuiltins.assume_allocated(socket);
|
||||||
|
sLast = socket;
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Socket createSocket() {
|
||||||
|
Socket socket = returnAllocatedSocket();
|
||||||
|
InferBuiltins.__set_taint_attribute(socket);
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - 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 javax.net.ssl;
|
||||||
|
|
||||||
|
import java.net.Socket;
|
||||||
|
import javax.net.SocketFactory;
|
||||||
|
import javax.net.ssl.SSLSession;
|
||||||
|
|
||||||
|
import com.facebook.infer.models.InferBuiltins;
|
||||||
|
import com.facebook.infer.models.InferUndefined;
|
||||||
|
|
||||||
|
public class HostnameVerifier {
|
||||||
|
|
||||||
|
public boolean verify(
|
||||||
|
String hostname,
|
||||||
|
SSLSession session) {
|
||||||
|
|
||||||
|
Socket socket = SocketFactory.getLastSocket();
|
||||||
|
|
||||||
|
if (InferUndefined.boolean_undefined()) {
|
||||||
|
// verification succeeded; we can untaint the socket
|
||||||
|
InferBuiltins.__set_untaint_attribute(socket);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// verification failed; we can't untaint the socket
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - 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 javax.net.ssl;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
import javax.net.SocketFactory;
|
||||||
|
|
||||||
|
import com.facebook.infer.models.InferBuiltins;
|
||||||
|
|
||||||
|
public class SSLSocketFactory extends SocketFactory {
|
||||||
|
|
||||||
|
public Socket createSocket(InetAddress addr, int i) throws IOException {
|
||||||
|
return super.createSocket();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Socket createSocket(InetAddress addr1, int i, InetAddress addr2, int j) throws IOException {
|
||||||
|
return super.createSocket();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Socket createSocket(String s, int i) throws IOException {
|
||||||
|
return super.createSocket();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Socket createSocket(String s, int i, InetAddress addr, int j) throws IOException {
|
||||||
|
return super.createSocket();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue