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

Commit 3f2c5282 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix potential arithmetic overflow in btif_config_set_bin"

parents f5f510a2 714908ce
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -413,6 +413,12 @@ bool btif_config_set_bin(const std::string& section, const std::string& key,

  if (length > 0) CHECK(value != NULL);

  size_t max_value = ((size_t)-1);
  if (((max_value - 1) / 2) < length) {
    LOG(ERROR) << __func__ << ": length too long";
    return false;
  }

  char* str = (char*)osi_calloc(length * 2 + 1);

  for (size_t i = 0; i < length; ++i) {