Merge "Check for null socket name in socket_connect_local." am: 1781dcc1c8

am: 00a23953a1

Change-Id: I063cfadb8bc0a6abb054e5c928705414e66594df
This commit is contained in:
Torne (Richard Coles)
2018-10-01 11:24:48 -07:00
committed by android-build-merger
2 changed files with 20 additions and 0 deletions

View File

@@ -58,6 +58,11 @@ socket_connect_local(JNIEnv *env, jobject object,
int ret;
int fd;
if (name == NULL) {
jniThrowNullPointerException(env, NULL);
return;
}
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (env->ExceptionCheck()) {

View File

@@ -22,6 +22,7 @@ import android.net.LocalSocket;
import android.net.LocalSocketAddress;
import android.test.MoreAsserts;
import android.test.suitebuilder.annotation.SmallTest;
import junit.framework.TestCase;
import java.io.FileDescriptor;
@@ -39,6 +40,20 @@ public class LocalSocketTest extends TestCase {
ls = new LocalSocket();
try {
ls.connect(new LocalSocketAddress(null));
fail("Expected NullPointerException");
} catch (NullPointerException e) {
// pass
}
try {
ls.bind(new LocalSocketAddress(null));
fail("Expected NullPointerException");
} catch (NullPointerException e) {
// pass
}
ls.connect(new LocalSocketAddress("android.net.LocalSocketTest"));
ls1 = ss.accept();