Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit acb7c0d8 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Make sure server response doesn't exceed maximum allowable length

am: 461fd829

Change-Id: If4b338fc070e5841cc3b8233297560336f15c4cb
parents 7ae27056 461fd829
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1682,7 +1682,13 @@ static void gattServerSendResponseNative(JNIEnv* env, jobject object,
  response.attr_value.len = 0;

  if (val != NULL) {
    if (env->GetArrayLength(val) < BTGATT_MAX_ATTR_LEN) {
      response.attr_value.len = (uint16_t)env->GetArrayLength(val);
    } else {
      android_errorWriteLog(0x534e4554, "78787521");
      response.attr_value.len = BTGATT_MAX_ATTR_LEN;
    }

    jbyte* array = env->GetByteArrayElements(val, 0);

    for (int i = 0; i != response.attr_value.len; ++i)