summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--service/jni/com_android_server_wifi_WifiNative.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/service/jni/com_android_server_wifi_WifiNative.cpp b/service/jni/com_android_server_wifi_WifiNative.cpp
index d2cbe11..a6d4f4e 100644
--- a/service/jni/com_android_server_wifi_WifiNative.cpp
+++ b/service/jni/com_android_server_wifi_WifiNative.cpp
@@ -763,15 +763,23 @@ static byte parseHexChar(char ch) {
}
static byte parseHexByte(const char * &str) {
+ if (str[0] == '\0') {
+ ALOGE("Passed an empty string");
+ return 0;
+ }
byte b = parseHexChar(str[0]);
- if (str[1] == ':' || str[1] == '\0') {
- str += 2;
- return b;
+ if (str[1] == '\0' || str[1] == ':') {
+ str ++;
} else {
b = b << 4 | parseHexChar(str[1]);
- str += 3;
- return b;
+ str += 2;
+ }
+
+ // Skip trailing delimiter if not at the end of the string.
+ if (str[0] != '\0') {
+ str++;
}
+ return b;
}
static void parseMacAddress(const char *str, mac_addr addr) {