mcexec: fix terminating zero after readlink()

Change-Id: Icb5432f157ceb2182d93e2d327cfa63ad02a8c0e
This commit is contained in:
Balazs Gerofi
2018-11-08 17:01:22 +09:00
parent 6f9fef2b13
commit 85c936a6cb

View File

@ -2827,17 +2827,20 @@ do_generic_syscall(
char proc_path[PATH_MAX];
char path[PATH_MAX];
struct stat sb;
int len;
sprintf(proc_path, "/proc/self/fd/%d", (int)w->sr.args[0]);
/* Get filename */
if (readlink(proc_path, path, sizeof(path)) < 0) {
if ((len = readlink(proc_path, path, sizeof(path))) < 0) {
fprintf(stderr, "%s: error: readlink() failed for %s\n",
__FUNCTION__, proc_path);
perror(": ");
goto out;
}
path[len] = 0;
/* Not in /sys? */
if (strncmp(path, "/sys/", 5))
goto out;