Fix mismatched buffer size in supplicant and WifiNative

The WifiNative response buffer is one byte smaller than the
amount of data that supplicant can throw at it. This can lead
to a problem where WifiNative gets mismatched answers for
its commands.

Bug: 24380015
Change-Id: Iadc0afa9390ca5c002022fc951951cb109eac22a
diff --git a/service/jni/com_android_server_wifi_WifiNative.cpp b/service/jni/com_android_server_wifi_WifiNative.cpp
index 1cce0b6..31166e3 100644
--- a/service/jni/com_android_server_wifi_WifiNative.cpp
+++ b/service/jni/com_android_server_wifi_WifiNative.cpp
@@ -32,7 +32,7 @@
 #include "jni_helper.h"
 #include "rtt.h"
 #include "wifi_hal_stub.h"
-#define REPLY_BUF_SIZE 4096 // wpa_supplicant's maximum size.
+#define REPLY_BUF_SIZE 4096 + 1         // wpa_supplicant's maximum size + 1 for nul
 #define EVENT_BUF_SIZE 2048
 
 namespace android {
@@ -138,7 +138,12 @@
     if (!doCommand(env, javaCommand, reply, sizeof(reply))) {
         return JNI_FALSE;
     }
-    return (strcmp(reply, "OK") == 0);
+    jboolean result = (strcmp(reply, "OK") == 0);
+    if (!result) {
+        ScopedUtfChars command(env, javaCommand);
+        ALOGI("command '%s' returned '%s", command.c_str(), reply);
+    }
+    return result;
 }
 
 // Send a command to the supplicant, and return the reply as a String.