Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars

@@ -18,16 +18,16 @@
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
  */
 /*
+ * Copyright (c) 2013 Gary Mills
+ *
  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 #include <sys/types.h>
 #include <sys/task.h>
 
 #include <alloca.h>
 #include <libproc.h>

@@ -694,11 +694,12 @@
          * allow this.
          */
         if (projname == NULL || getuid() == (uid_t)0)
                 return (pw);
 
-        (void) strcpy(username, pw->pw_name);
+        (void) strncpy(username, pw->pw_name, sizeof (username) - 1);
+        username[sizeof (username) - 1] = '\0';
 
         if (inproj(username, projname, prbuf, PROJECT_BUFSZ) == 0) {
                 char **u;
                 tmp_name = NULL;