summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorvangyzen <vangyzen@FreeBSD.org>2016-12-15 01:45:31 +0000
committervangyzen <vangyzen@FreeBSD.org>2016-12-15 01:45:31 +0000
commit44d7841dbbc1eb424e8c05dda0244b5832238953 (patch)
tree2146c306c55d2cd1106d8cda9f66760d8864bda2 /sys/kern
parent60185485a783f3abc93ffe265af62d50082984b8 (diff)
downloadFreeBSD-src-44d7841dbbc1eb424e8c05dda0244b5832238953.zip
FreeBSD-src-44d7841dbbc1eb424e8c05dda0244b5832238953.tar.gz
MFC r309460
thr_set_name(): silently truncate the given name as needed Instead of failing with ENAMETOOLONG, which is swallowed by pthread_set_name_np() anyway, truncate the given name to MAXCOMLEN+1 bytes. This is more likely what the user wants, and saves the caller from truncating it before the call (which was the only recourse). The man page changes were not merged because thr_set_name.2 does not exist on stable/10. Sponsored by: Dell EMC
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_thr.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c
index 74050ff..63e4ed0 100644
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -569,8 +569,11 @@ sys_thr_set_name(struct thread *td, struct thr_set_name_args *uap)
error = 0;
name[0] = '\0';
if (uap->name != NULL) {
- error = copyinstr(uap->name, name, sizeof(name),
- NULL);
+ error = copyinstr(uap->name, name, sizeof(name), NULL);
+ if (error == ENAMETOOLONG) {
+ error = copyin(uap->name, name, sizeof(name) - 1);
+ name[sizeof(name) - 1] = '\0';
+ }
if (error)
return (error);
}
OpenPOWER on IntegriCloud