summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPaul Stewart <pstew@google.com>2016-06-07 22:13:01 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-06-07 22:13:01 +0000
commit04fdb2ce414b6175aad402fa459b3988a3238e97 (patch)
tree836b840dcef2010a457ba68455e0cf4fdee6ca36 /service
parenta15a2ee69156fa6fff09c0dd9b8182cb8fafde1c (diff)
parent0f37e416a42451deeaf0bbe7bfca8232d050f39e (diff)
Deal correctly with short strings am: 1921acbf2c am: 49fefde164 am: 444e06c469
am: 0f37e416a4 Change-Id: I4794005c53ae7d99627de25722c846c2a45b856c
Diffstat (limited to 'service')
-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 3c7270a94..14f7b9631 100644
--- a/service/jni/com_android_server_wifi_WifiNative.cpp
+++ b/service/jni/com_android_server_wifi_WifiNative.cpp
@@ -692,15 +692,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) {