Merge "Tell bionic when we overwrite argv[0]." am: bf7cb1ca91 am: 3811c9dcdb

Change-Id: Ibd6adf1f08bef5962bf58f6cd4bcefa198c02fb5
This commit is contained in:
Elliott Hughes
2020-04-21 23:44:54 +00:00
committed by Automerger Merge Worker

View File

@@ -301,6 +301,8 @@ AndroidRuntime::~AndroidRuntime()
}
void AndroidRuntime::setArgv0(const char* argv0, bool setProcName) {
// Set the kernel's task name, for as much of the name as we can fit.
// The kernel's TASK_COMM_LEN minus one for the terminating NUL == 15.
if (setProcName) {
int len = strlen(argv0);
if (len < 15) {
@@ -309,8 +311,14 @@ void AndroidRuntime::setArgv0(const char* argv0, bool setProcName) {
pthread_setname_np(pthread_self(), argv0 + len - 15);
}
}
// Directly change the memory pointed to by argv[0].
memset(mArgBlockStart, 0, mArgBlockLength);
strlcpy(mArgBlockStart, argv0, mArgBlockLength);
// Let bionic know that we just did that, because __progname points
// into argv[0] (https://issuetracker.google.com/152893281).
setprogname(mArgBlockStart);
}
status_t AndroidRuntime::callMain(const String8& className, jclass clazz,