diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-20 09:02:03 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-20 09:04:45 +0200 |
commit | 9c291f2cc0e0e76869c315b5c7e7883827b5ae95 (patch) | |
tree | b7be6ed57f3ed1886e92c26bfc4418f7f8ad6833 | |
parent | 25128176c46b169cdec2c18b5730c36a940f6eb0 (diff) | |
download | busybox-w32-9c291f2cc0e0e76869c315b5c7e7883827b5ae95.tar.gz busybox-w32-9c291f2cc0e0e76869c315b5c7e7883827b5ae95.tar.bz2 busybox-w32-9c291f2cc0e0e76869c315b5c7e7883827b5ae95.zip |
taskset: fix for PID longer than 12 chars
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@googlemail.com>
-rw-r--r-- | util-linux/taskset.c | 5 |
1 files 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) | |||
346 | aff = NULL; | 346 | aff = NULL; |
347 | 347 | ||
348 | if (opts & OPT_a) { | 348 | if (opts & OPT_a) { |
349 | char dn[sizeof("/proc/%s/task") + 3 * sizeof(int)]; | 349 | char *dn; |
350 | DIR *dir; | 350 | DIR *dir; |
351 | struct dirent *ent; | 351 | struct dirent *ent; |
352 | 352 | ||
353 | sprintf(dn, "/proc/%s/task", pid_str); | 353 | dn = xasprintf("/proc/%s/task", pid_str); |
354 | dir = opendir(dn); | 354 | dir = opendir(dn); |
355 | IF_FEATURE_CLEAN_UP(free(dn);) | ||
355 | if (!dir) { | 356 | if (!dir) { |
356 | goto no_threads; | 357 | goto no_threads; |
357 | } | 358 | } |