summaryrefslogtreecommitdiffstats
path: root/service/jni
diff options
context:
space:
mode:
authorPaul Stewart <pstew@google.com>2016-06-07 22:27:33 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-06-07 22:27:33 +0000
commit848c1f089f91ee82cb829f038a74b6df8850d937 (patch)
tree1356a5917cc12279e2b60d545bee7ae857c9089d /service/jni
parentd232dec2ddf76d961160f55a5299691de35c597c (diff)
parentad0d0a48952e025838992b6a1b0cd143f1915ced (diff)
downloadandroid_frameworks_opt_net_wifi-848c1f089f91ee82cb829f038a74b6df8850d937.tar.gz
android_frameworks_opt_net_wifi-848c1f089f91ee82cb829f038a74b6df8850d937.tar.bz2
android_frameworks_opt_net_wifi-848c1f089f91ee82cb829f038a74b6df8850d937.zip
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 Change-Id: I5e6dcdf2bd4945c694e94e2e381cadf4a440aeab
Diffstat (limited to 'service/jni')
-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 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) {