proc/readproc.c: Harden simple_nextpid().
Replace memcpy+strcpy with snprintf.
This commit is contained in:
parent
263c0ebdd8
commit
1b8ec51013
@ -1224,8 +1224,7 @@ static int simple_nextpid(PROCTAB *restrict const PT, proc_t *restrict const p)
|
|||||||
}
|
}
|
||||||
p->tgid = strtoul(ent->d_name, NULL, 10);
|
p->tgid = strtoul(ent->d_name, NULL, 10);
|
||||||
p->tid = p->tgid;
|
p->tid = p->tgid;
|
||||||
memcpy(path, "/proc/", 6);
|
snprintf(path, PROCPATHLEN, "/proc/%s", ent->d_name);
|
||||||
strcpy(path+6, ent->d_name); // trust /proc to not contain evil top-level entries
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user