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

Commit 9858b8ea authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8512771 from d02ad101 to tm-d1-release

Change-Id: Iaa536481581c79ad33de5cfa91df316a079f2260
parents e33f0459 d02ad101
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -140,6 +140,20 @@ static void log_processes(FILE* log) {
static void bootchart_thread_main() {
  LOG(INFO) << "Bootcharting started";

  // Unshare the mount namespace of this thread so that the init process itself can switch
  // the mount namespace later while this thread is still running.
  // Otherwise, setns() call invoked as part of `enter_default_mount_ns` fails with EINVAL.
  //
  // Note that after unshare()'ing the mount namespace from the main thread, this thread won't
  // receive mount/unmount events from the other mount namespace unless the events are happening
  // from under a sharable mount.
  //
  // The bootchart thread is safe to unshare the mount namespace because it only reads from /proc
  // and write to /data which are not private mounts.
  if (unshare(CLONE_NEWNS) == -1) {
      PLOG(ERROR) << "Cannot create mount namespace";
      return;
  }
  // Open log files.
  auto stat_log = fopen_unique("/data/bootchart/proc_stat.log", "we");
  if (!stat_log) return;
+6 −8
Original line number Diff line number Diff line
@@ -279,12 +279,10 @@ ssize_t VectorImpl::replaceAt(const void* prototype, size_t index)

ssize_t VectorImpl::removeItemsAt(size_t index, size_t count)
{
    ALOG_ASSERT((index+count)<=size(),
        "[%p] remove: index=%d, count=%d, size=%d",
               this, (int)index, (int)count, (int)size());

    if ((index+count) > size())
        return BAD_VALUE;
    size_t end;
    LOG_ALWAYS_FATAL_IF(__builtin_add_overflow(index, count, &end), "overflow: index=%zu count=%zu",
                        index, count);
    if (end > size()) return BAD_VALUE;
    _shrink(index, count);
    return index;
}
+9 −0
Original line number Diff line number Diff line
@@ -136,4 +136,13 @@ TEST_F(VectorTest, editArray_Shared) {
  }
}

TEST_F(VectorTest, removeItemsAt_overflow) {
    android::Vector<int> v;
    for (int i = 0; i < 666; i++) v.add(i);

    ASSERT_DEATH(v.removeItemsAt(SIZE_MAX, 666), "overflow");
    ASSERT_DEATH(v.removeItemsAt(666, SIZE_MAX), "overflow");
    ASSERT_DEATH(v.removeItemsAt(SIZE_MAX, SIZE_MAX), "overflow");
}

} // namespace android