diff options
author | Paul Stewart <pstew@google.com> | 2016-06-07 22:49:42 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-06-07 22:49:42 +0000 |
commit | c7c2741335d43cdc9af92e8a2e415f07ad78a4a2 (patch) | |
tree | 2597430fc7ea395e29c70a666b720a91f9eb9ed7 /service | |
parent | 25a6b725a05c6a9871f81d1b2db1802e8ac0e8bb (diff) | |
parent | 848c1f089f91ee82cb829f038a74b6df8850d937 (diff) |
Deal correctly with short strings am: 1921acbf2c am: 49fefde164 am: 444e06c469 am: 0f37e416a4 am: 04fdb2ce41 am: 05e029710c am: 8e0899faab am: 15a72380b1 am: a9c9a971cf am: ad0d0a4895
am: 848c1f089f
Change-Id: I4101a56b1765437364cc68a48deff2d32a9949a4
Diffstat (limited to 'service')
-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 6afafd027..703a1d272 100644 --- a/service/jni/com_android_server_wifi_WifiNative.cpp +++ b/service/jni/com_android_server_wifi_WifiNative.cpp @@ -659,15 +659,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) { |