release-request-762540b1-1728-41bc-a9ce-e977f3e2683f-for-git_nyc-mr2-pixel-monthly-release-3888830 snap-temp-L22300000056915770

Change-Id: If660b2507ebb0fdf5657c3f9f4ae65e286bd87fe
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c
index 6d90589..05a2048 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -404,7 +404,7 @@
         }
 
 
-        if (fd > 0 && add_tid_to_cgroup(tid, fd) != 0) {
+        if (add_tid_to_cgroup(tid, fd) != 0) {
             if (errno != ESRCH && errno != ENOENT)
                 return -errno;
         }
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index 49097ce..986ee72 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -386,14 +386,6 @@
   const uint8_t* const cd_end = cd_ptr + cd_length;
   const uint8_t* ptr = cd_ptr;
   for (uint16_t i = 0; i < num_entries; i++) {
-    if (ptr > cd_end - sizeof(CentralDirectoryRecord)) {
-      ALOGW("Zip: ran off the end (at %" PRIu16 ")", i);
-#if defined(__ANDROID__)
-      android_errorWriteLog(0x534e4554, "36392138");
-#endif
-      return -1;
-    }
-
     const CentralDirectoryRecord* cdr =
         reinterpret_cast<const CentralDirectoryRecord*>(ptr);
     if (cdr->record_signature != CentralDirectoryRecord::kSignature) {
@@ -401,6 +393,11 @@
       return -1;
     }
 
+    if (ptr + sizeof(CentralDirectoryRecord) > cd_end) {
+      ALOGW("Zip: ran off the end (at %" PRIu16 ")", i);
+      return -1;
+    }
+
     const off64_t local_header_offset = cdr->local_file_header_offset;
     if (local_header_offset >= archive->directory_offset) {
       ALOGW("Zip: bad LFH offset %" PRId64 " at entry %" PRIu16,
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 7dc9e55..df60f65 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -145,6 +145,15 @@
     write /dev/cpuctl/cpu.rt_period_us 1000000
     write /dev/cpuctl/cpu.rt_runtime_us 950000
 
+    mkdir /dev/cpuctl/bg_non_interactive
+    chown system system /dev/cpuctl/bg_non_interactive/tasks
+    chmod 0666 /dev/cpuctl/bg_non_interactive/tasks
+    # 5.0 %
+    write /dev/cpuctl/bg_non_interactive/cpu.shares 52
+    write /dev/cpuctl/bg_non_interactive/cpu.rt_period_us 1000000
+    # active FIFO threads will never be in BG
+    write /dev/cpuctl/bg_non_interactive/cpu.rt_runtime_us 10000
+
     # sets up initial cpusets for ActivityManager
     mkdir /dev/cpuset
     mount cpuset none /dev/cpuset