svn commit: r310099 - stable/10/sys/kern

Eric van Gyzen vangyzen at FreeBSD.org
Thu Dec 15 01:45:33 UTC 2016


Author: vangyzen
Date: Thu Dec 15 01:45:31 2016
New Revision: 310099
URL: https://svnweb.freebsd.org/changeset/base/310099

Log:
  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

Modified:
  stable/10/sys/kern/kern_thr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_thr.c
==============================================================================
--- stable/10/sys/kern/kern_thr.c	Wed Dec 14 23:36:32 2016	(r310098)
+++ stable/10/sys/kern/kern_thr.c	Thu Dec 15 01:45:31 2016	(r310099)
@@ -569,8 +569,11 @@ sys_thr_set_name(struct thread *td, stru
 	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);
 	}


More information about the svn-src-all mailing list