if the element attribute string is more than the maximum length, try to send partial attribute instead of empty attribute string .
issue 8470888
Change-Id: Ibfc3a25839bd07bd99dbb3328f56aad1d21720ea
diff --git a/jni/com_android_bluetooth_avrcp.cpp b/jni/com_android_bluetooth_avrcp.cpp
index ee7083e..125ac4b 100644
--- a/jni/com_android_bluetooth_avrcp.cpp
+++ b/jni/com_android_bluetooth_avrcp.cpp
@@ -226,14 +226,15 @@
env->DeleteLocalRef(text);
break;
}
+
+ pAttrs[i].attr_id = attr[i];
if (strlen(textStr) >= BTRC_MAX_ATTR_STR_LEN) {
ALOGE("get_element_attr_rsp: string length exceed maximum");
- env->ReleaseStringUTFChars(text, textStr);
- env->DeleteLocalRef(text);
- break;
+ strncpy((char *)pAttrs[i].text, textStr, BTRC_MAX_ATTR_STR_LEN-1);
+ pAttrs[i].text[BTRC_MAX_ATTR_STR_LEN-1] = 0;
+ } else {
+ strcpy((char *)pAttrs[i].text, textStr);
}
- pAttrs[i].attr_id = attr[i];
- strcpy((char *)pAttrs[i].text, textStr);
env->ReleaseStringUTFChars(text, textStr);
env->DeleteLocalRef(text);
}