Merge "Fix read past end of malloc block in logd"
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index 0ca90c3..d4be25b 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -218,7 +218,7 @@
}
if (proc_info.pid != expected_pid) {
- LOG(FATAL) << "pid mismatch: expected " << expected_pid << ", actual " << proc_info.ppid;
+ LOG(FATAL) << "pid mismatch: expected " << expected_pid << ", actual " << proc_info.pid;
}
}
@@ -254,7 +254,7 @@
}
if (!android::base::ParseInt(argv[2], &pseudothread_tid, 1, std::numeric_limits<pid_t>::max())) {
- LOG(FATAL) << "invalid pseudothread tid: " << argv[1];
+ LOG(FATAL) << "invalid pseudothread tid: " << argv[2];
}
android::procinfo::ProcessInfo target_info;
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index a5de83a..b1dc01a 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -81,7 +81,7 @@
va_start(args, fmt);
char buf[4096];
- vsnprintf(buf, sizeof(buf), fmt, args);
+ __libc_format_buffer_va_list(buf, sizeof(buf), fmt, args);
fatal("%s: %s", buf, strerror(err));
}
@@ -256,8 +256,9 @@
char main_tid[10];
char pseudothread_tid[10];
- snprintf(main_tid, sizeof(main_tid), "%d", thread_info->crashing_tid);
- snprintf(pseudothread_tid, sizeof(pseudothread_tid), "%d", thread_info->pseudothread_tid);
+ __libc_format_buffer(main_tid, sizeof(main_tid), "%d", thread_info->crashing_tid);
+ __libc_format_buffer(pseudothread_tid, sizeof(pseudothread_tid), "%d", thread_info->pseudothread_tid);
+
execl(CRASH_DUMP_PATH, CRASH_DUMP_NAME, main_tid, pseudothread_tid, nullptr);
fatal_errno("exec failed");
diff --git a/fs_mgr/Android.mk b/fs_mgr/Android.mk
index 4369e5a..6939428 100644
--- a/fs_mgr/Android.mk
+++ b/fs_mgr/Android.mk
@@ -29,8 +29,7 @@
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
system/vold \
- system/extras/ext4_utils \
- bootable/recovery
+ system/extras/ext4_utils
LOCAL_MODULE:= libfs_mgr
LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
diff --git a/fs_mgr/fs_mgr_slotselect.cpp b/fs_mgr/fs_mgr_slotselect.cpp
index e957f6b..b30417f 100644
--- a/fs_mgr/fs_mgr_slotselect.cpp
+++ b/fs_mgr/fs_mgr_slotselect.cpp
@@ -33,53 +33,6 @@
#include "fs_mgr.h"
#include "fs_mgr_priv.h"
-#include "bootloader.h"
-
-// Copies slot_suffix from misc into |out_suffix|. Returns 0 on
-// success, -1 on error or if there is no non-empty slot_suffix.
-static int get_active_slot_suffix_from_misc(struct fstab *fstab,
- char *out_suffix,
- size_t suffix_len)
-{
- int n;
- int misc_fd;
- ssize_t num_read;
- struct bootloader_message_ab msg;
-
- misc_fd = -1;
- for (n = 0; n < fstab->num_entries; n++) {
- if (strcmp(fstab->recs[n].mount_point, "/misc") == 0) {
- misc_fd = open(fstab->recs[n].blk_device, O_RDONLY);
- if (misc_fd == -1) {
- PERROR << "Error opening misc partition '"
- << fstab->recs[n].blk_device << "'";
- return -1;
- } else {
- break;
- }
- }
- }
-
- if (misc_fd == -1) {
- LERROR << "Error finding misc partition";
- return -1;
- }
-
- num_read = TEMP_FAILURE_RETRY(read(misc_fd, &msg, sizeof(msg)));
- // Linux will never return partial reads when reading from block
- // devices so no need to worry about them.
- if (num_read != sizeof(msg)) {
- PERROR << "Error reading bootloader_message";
- close(misc_fd);
- return -1;
- }
- close(misc_fd);
- if (msg.slot_suffix[0] == '\0')
- return -1;
- strncpy(out_suffix, msg.slot_suffix, suffix_len);
- return 0;
-}
-
// finds slot_suffix in androidboot.slot_suffix kernel command line argument
// or in the device tree node at /firmware/android/slot_suffix property
static int get_active_slot_suffix_from_kernel(char *out_suffix,
@@ -123,11 +76,10 @@
return -1;
}
-// Gets slot_suffix from either the kernel cmdline / device tree / firmware
-// or the misc partition. Sets |out_suffix| on success and returns 0. Returns
-// -1 if slot_suffix could not be determined.
-static int get_active_slot_suffix(struct fstab *fstab, char *out_suffix,
- size_t suffix_len)
+// Gets slot_suffix from either the kernel cmdline / device tree. Sets
+// |out_suffix| on success and returns 0. Returns -1 if slot_suffix could not
+// be determined.
+static int get_active_slot_suffix(char *out_suffix, size_t suffix_len)
{
char propbuf[PROPERTY_VALUE_MAX];
@@ -140,22 +92,14 @@
return 0;
}
- // if the property is not set, we are either being invoked too early
- // or the slot suffix in mentioned in the misc partition. If its
- // "too early", try to find the slotsuffix ourselves in the kernel command
- // line or the device tree
+ // if the property is not set, we are probably being invoked early during
+ // boot. Try to find the slotsuffix ourselves in the kernel command line
+ // or the device tree
if (get_active_slot_suffix_from_kernel(out_suffix, suffix_len) == 0) {
LINFO << "Using slot suffix '" << out_suffix << "' from kernel";
return 0;
}
- // If we couldn't get the suffix from the kernel cmdline, try the
- // the misc partition.
- if (get_active_slot_suffix_from_misc(fstab, out_suffix, suffix_len) == 0) {
- LINFO << "Using slot suffix '" << out_suffix << "' from misc";
- return 0;
- }
-
LERROR << "Error determining slot_suffix";
return -1;
@@ -174,8 +118,7 @@
if (!got_suffix) {
memset(suffix, '\0', sizeof(suffix));
- if (get_active_slot_suffix(fstab, suffix,
- sizeof(suffix) - 1) != 0) {
+ if (get_active_slot_suffix(suffix, sizeof(suffix) - 1) != 0) {
return -1;
}
got_suffix = 1;
diff --git a/init/init.cpp b/init/init.cpp
index 9c1e23b..7f7eb2f 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -47,6 +47,7 @@
#include <cutils/iosched_policy.h>
#include <cutils/list.h>
#include <cutils/sockets.h>
+#include <libavb/libavb.h>
#include <private/android_filesystem_config.h>
#include <fstream>
@@ -959,6 +960,9 @@
property_set("ro.boottime.init", getenv("INIT_STARTED_AT"));
property_set("ro.boottime.init.selinux", getenv("INIT_SELINUX_TOOK"));
+ // Set libavb version for Framework-only OTA match in Treble build.
+ property_set("ro.boot.init.avb_version", std::to_string(AVB_MAJOR_VERSION).c_str());
+
// Clean up our environment.
unsetenv("INIT_SECOND_STAGE");
unsetenv("INIT_STARTED_AT");
diff --git a/libutils/RefBase.cpp b/libutils/RefBase.cpp
index 1f8395b..4252ba6 100644
--- a/libutils/RefBase.cpp
+++ b/libutils/RefBase.cpp
@@ -22,7 +22,6 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <typeinfo>
#include <unistd.h>
#include <utils/RefBase.h>
diff --git a/rootdir/init.zygote64_32.rc b/rootdir/init.zygote64_32.rc
index 36bb443..09db7b0 100644
--- a/rootdir/init.zygote64_32.rc
+++ b/rootdir/init.zygote64_32.rc
@@ -13,7 +13,7 @@
onrestart restart wificond
writepid /dev/cpuset/foreground/tasks
-service zygote_secondary /system/bin/app_process32 -Xzygote /system/bin --zygote --socket-name=zygote_secondary
+service zygote_secondary /system/bin/app_process32 -Xzygote /system/bin --zygote --socket-name=zygote_secondary --enable-lazy-preload
class main
priority -20
user root