[git commit] taskset: fix for PID longer than 12 chars
Denys Vlasenko
vda.linux at googlemail.com
Sun Jun 20 07:04:45 UTC 2021
commit: https://git.busybox.net/busybox/commit/?id=9c291f2cc0e0e76869c315b5c7e7883827b5ae95
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
Should we validate that PID is a number for "taskset -ap PID"?
We don't actually need it, and pathological input like
"../../DIR_WITH_LOTS_OF_PIDS" can only cause "taskset"ing
of many pids. Which is something user can do anyway.
function old new delta
taskset_main 190 181 -9
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
util-linux/taskset.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/util-linux/taskset.c b/util-linux/taskset.c
index abec04933..47e989792 100644
--- a/util-linux/taskset.c
+++ b/util-linux/taskset.c
@@ -346,12 +346,13 @@ int taskset_main(int argc UNUSED_PARAM, char **argv)
aff = NULL;
if (opts & OPT_a) {
- char dn[sizeof("/proc/%s/task") + 3 * sizeof(int)];
+ char *dn;
DIR *dir;
struct dirent *ent;
- sprintf(dn, "/proc/%s/task", pid_str);
+ dn = xasprintf("/proc/%s/task", pid_str);
dir = opendir(dn);
+ IF_FEATURE_CLEAN_UP(free(dn);)
if (!dir) {
goto no_threads;
}
More information about the busybox-cvs
mailing list