From 86f56a135a7f04f6217016bd8b4c5f1ac0677a85 Mon Sep 17 00:00:00 2001 From: Ye Jiao Date: Tue, 18 May 2021 15:21:36 +0800 Subject: [PATCH] Fix memory access violation in NetworkStack Fix memory access violation in com_android_networkstack_tethering_BpfUtils.cpp caused by invalid format string in com_android_networkstack_tethering_BpfUtils_isEthernet. If rv is not valid, jniThrowException will format a string using "Unknown hardware address type %s on interface %s". However, rv is an int but here "%s" is used in fmt string, thus causing access violation of memory. Use "%d" instead of "%s" for int. Bug: 188757793 Change-Id: I9d8ec0708efd747e24b3b3ffed5336434d4f64a7 --- Tethering/jni/com_android_networkstack_tethering_BpfUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tethering/jni/com_android_networkstack_tethering_BpfUtils.cpp b/Tethering/jni/com_android_networkstack_tethering_BpfUtils.cpp index 1611f9d514..2fb59858e4 100644 --- a/Tethering/jni/com_android_networkstack_tethering_BpfUtils.cpp +++ b/Tethering/jni/com_android_networkstack_tethering_BpfUtils.cpp @@ -183,7 +183,7 @@ static jboolean com_android_networkstack_tethering_BpfUtils_isEthernet(JNIEnv* e return false; default: jniThrowExceptionFmt(env, "java/io/IOException", - "Unknown hardware address type %s on interface %s", rv, + "Unknown hardware address type %d on interface %s", rv, interface.c_str()); return false; }