Handle GET_POWER failures
Return a failure when GET_POWER returns a non-conforming
format
Bug: 4380317
Change-Id: If1ce73572ae261cd6998e4289e21112c88859437
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp
index fb029e6..35d8dc3 100644
--- a/core/jni/android_net_wifi_Wifi.cpp
+++ b/core/jni/android_net_wifi_Wifi.cpp
@@ -402,7 +402,9 @@
}
// reply comes back in the form "powermode = XX" where XX is the
// number we're interested in.
- sscanf(reply, "%*s = %u", &power);
+ if (sscanf(reply, "%*s = %u", &power) != 1) {
+ return (jint)-1;
+ }
return (jint)power;
}