From e6cf914c3fea45d237e40c675ff20dea812d699d Mon Sep 17 00:00:00 2001 From: Taras Antoshchuk Date: Fri, 13 May 2022 18:15:11 +0200 Subject: [PATCH] Don't throw in socket_read if socket_read_all returns < 0. All codepaths in socket_read_all that return a negative value have already thrown an exception. socket_read should not throw again. This causes debuggagle apps to crash with a JNI failure if LocalSocket#read gets an error. Test: atest CtsNetTestCases Bug: 229813087 Change-Id: I2a04a799d3748c221f8555fa7afc40d73f0f392c --- core/jni/android_net_LocalSocketImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/jni/android_net_LocalSocketImpl.cpp b/core/jni/android_net_LocalSocketImpl.cpp index 42cf1f479122f..9bd07007586c2 100644 --- a/core/jni/android_net_LocalSocketImpl.cpp +++ b/core/jni/android_net_LocalSocketImpl.cpp @@ -257,7 +257,7 @@ static jint socket_read (JNIEnv *env, jobject object, jobject fileDescriptor) err = socket_read_all(env, object, fd, &buf, 1); if (err < 0) { - jniThrowIOException(env, errno); + // socket_read_all has already thrown return (jint)0; }