Merge "BlobCache: fix uninitialized memory" into lmp-dev
diff --git a/adb/services.c b/adb/services.c
index 2875ce0..e61371a 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -206,7 +206,6 @@
fprintf(stderr, "error: create_subproc_pty not implemented on Win32 (%s %s %s)\n", cmd, arg0, arg1);
return -1;
#else /* !HAVE_WIN32_PROC */
- char *devname;
int ptm;
ptm = unix_open("/dev/ptmx", O_RDWR | O_CLOEXEC); // | O_NOCTTY);
@@ -215,8 +214,8 @@
return -1;
}
- if(grantpt(ptm) || unlockpt(ptm) ||
- ((devname = (char*) ptsname(ptm)) == 0)){
+ char devname[64];
+ if(grantpt(ptm) || unlockpt(ptm) || ptsname_r(ptm, devname, sizeof(devname)) != 0) {
printf("[ trouble with /dev/ptmx - %s ]\n", strerror(errno));
adb_close(ptm);
return -1;
diff --git a/debuggerd/tombstone.cpp b/debuggerd/tombstone.cpp
index e447190..df982a9 100644
--- a/debuggerd/tombstone.cpp
+++ b/debuggerd/tombstone.cpp
@@ -210,6 +210,12 @@
}
}
}
+ // Blacklist logd, logd.reader, logd.writer, logd.auditd, logd.control ...
+ static const char logd[] = "logd";
+ if (!strncmp(threadname, logd, sizeof(logd) - 1)
+ && (!threadname[sizeof(logd) - 1] || (threadname[sizeof(logd) - 1] == '.'))) {
+ log->should_retrieve_logcat = false;
+ }
char procnamebuf[1024];
char* procname = NULL;
@@ -450,6 +456,10 @@
bool first = true;
struct logger_list* logger_list;
+ if (!log->should_retrieve_logcat) {
+ return;
+ }
+
logger_list = android_logger_list_open(
android_name_to_log_id(filename), O_RDONLY | O_NONBLOCK, tail, pid);
diff --git a/debuggerd/utility.cpp b/debuggerd/utility.cpp
index a163344..9a30fe3 100644
--- a/debuggerd/utility.cpp
+++ b/debuggerd/utility.cpp
@@ -59,6 +59,8 @@
void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) {
bool write_to_tombstone = (log->tfd != -1);
bool write_to_logcat = is_allowed_in_logcat(ltype)
+ && log->crashed_tid != -1
+ && log->current_tid != -1
&& (log->crashed_tid == log->current_tid);
bool write_to_activitymanager = (log->amfd != -1);
diff --git a/debuggerd/utility.h b/debuggerd/utility.h
index 518305d..82413b8 100644
--- a/debuggerd/utility.h
+++ b/debuggerd/utility.h
@@ -37,7 +37,7 @@
#endif
-typedef struct {
+struct log_t{
/* tombstone file descriptor */
int tfd;
/* Activity Manager socket file descriptor */
@@ -46,7 +46,12 @@
pid_t crashed_tid;
// The tid of the thread we are currently working with.
pid_t current_tid;
-} log_t;
+ // logd daemon crash, can block asking for logcat data, allow suppression.
+ bool should_retrieve_logcat;
+
+ log_t()
+ : tfd(-1), amfd(-1), crashed_tid(-1), current_tid(-1), should_retrieve_logcat(true) {}
+};
// List of types of logs to simplify the logging decision in _LOG
enum logtype {
diff --git a/logwrapper/logwrap.c b/logwrapper/logwrap.c
index d47c9b5..3a6276e 100644
--- a/logwrapper/logwrap.c
+++ b/logwrapper/logwrap.c
@@ -477,7 +477,6 @@
pid_t pid;
int parent_ptty;
int child_ptty;
- char *child_devname = NULL;
struct sigaction intact;
struct sigaction quitact;
sigset_t blockset;
@@ -498,8 +497,9 @@
goto err_open;
}
+ char child_devname[64];
if (grantpt(parent_ptty) || unlockpt(parent_ptty) ||
- ((child_devname = (char*)ptsname(parent_ptty)) == 0)) {
+ ptsname_r(parent_ptty, child_devname, sizeof(child_devname)) != 0) {
ERROR("Problem with /dev/ptmx\n");
rc = -1;
goto err_ptty;