diff options
author | Paul Stewart <pstew@google.com> | 2016-06-07 22:25:04 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-06-07 22:25:04 +0000 |
commit | ad0d0a48952e025838992b6a1b0cd143f1915ced (patch) | |
tree | 3cef48736b0022b5270a13ff3b778089816bc014 | |
parent | 8cb1589234aa116c49bba15ca616c7beeae0cebe (diff) | |
parent | a9c9a971cf1a68113541a7bb5e6b6ce9c85799f3 (diff) |
Deal correctly with short strings am: 1921acbf2c am: 49fefde164 am: 444e06c469 am: 0f37e416a4 am: 04fdb2ce41 am: 05e029710c am: 8e0899faab am: 15a72380b1
am: a9c9a971cf
Change-Id: Ibe80f3d455c6f7ccdf61a03ce6da5b9f01e7a171
-rw-r--r-- | service/jni/com_android_server_wifi_WifiNative.cpp | 18 |
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 765fd9552..49c9b78d2 100644 --- a/service/jni/com_android_server_wifi_WifiNative.cpp +++ b/service/jni/com_android_server_wifi_WifiNative.cpp @@ -658,15 +658,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) { |