Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 086293c5 authored by chenguanyou's avatar chenguanyou
Browse files

[BugFix][HWASAN] stack-buffer-overflow



Test: hwasan

Change-Id: I95be4202a35d1f4876b382350a6f1fdd64d2548c
Signed-off-by: default avatarchenguanyou <chenguanyou@xiaomi.com>
parent 36f5f53a
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -262,8 +262,12 @@ void android_os_Process_setProcessGroup(JNIEnv* env, jobject clazz, int pid, jin
        sprintf(proc_path, "/proc/%d/cmdline", pid);
        sprintf(proc_path, "/proc/%d/cmdline", pid);
        fd = open(proc_path, O_RDONLY | O_CLOEXEC);
        fd = open(proc_path, O_RDONLY | O_CLOEXEC);
        if (fd >= 0) {
        if (fd >= 0) {
            int rc = read(fd, cmdline, sizeof(cmdline)-1);
            ssize_t rc = read(fd, cmdline, sizeof(cmdline) - 1);
            if (rc < 0) {
                ALOGE("read /proc/%d/cmdline (%s)", pid, strerror(errno));
            } else {
                cmdline[rc] = 0;
                cmdline[rc] = 0;
            }
            close(fd);
            close(fd);
        }
        }