Skip to content

Commit 46a0095

Browse files
fix #18
1 parent 0fb212d commit 46a0095

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

linux-user/syscall.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8496,6 +8496,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
84968496
envc = 0;
84978497
guest_envp = arg3;
84988498
for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) {
8499+
if (!get_user_ual(addr, gp)) {
8500+
goto execve_efault;
8501+
}
8502+
if (!addr) {
8503+
break;
8504+
}
84998505
/* QASAN: remove preloaded library */
85008506
if (!getenv("QASAN_PRESERVE_EXECVE")) {
85018507
/*
@@ -8508,25 +8514,22 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
85088514
return -TARGET_EFAULT;
85098515
}
85108516
char *env = lock_user(VERIFY_WRITE, gp, (long)(len + 1), 0);
8517+
if (!env)
8518+
goto execve_efault;
85118519
if (!strncmp("LD_PRELOAD=", env, 11)) {
8512-
env += 11;
8513-
char *libqasan = strstr(env, "libqasan.so");
8514-
if (libqasan) {
8515-
*libqasan = 0;
8520+
char *p, *q, *r;
8521+
if ((q = r = strstr(env +11, "libqasan.so")) != NULL) {
8522+
size_t mlen = strlen("libqasan.so");
8523+
while ((r = strstr(p = r + mlen, sub)) != NULL) {
8524+
while (p < r)
8525+
*q++ = *p++;
8526+
}
8527+
while ((*q++ = *p++) != '\0')
8528+
continue;
85168529
}
8530+
85178531
}
85188532
unlock_user(env, gp, (long)(len + 1));
8519-
} else {
8520-
/*
8521-
* otherwise use the original behavior to check for valid
8522-
* addresses and NULL (end-of-list).
8523-
*/
8524-
if (!get_user_ual(addr, gp)) {
8525-
return -TARGET_EFAULT;
8526-
}
8527-
if (!addr) {
8528-
break;
8529-
}
85308533
}
85318534
envc++;
85328535
}

0 commit comments

Comments
 (0)