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>

@@ -652,11 +652,11 @@
  * function will re-use the memory previously returned.
  */
 static struct passwd *
 match_user(uid_t uid, char *projname, int is_my_uid)
 {
-        char prbuf[PROJECT_BUFSZ], username[LOGNAME_MAX+1];
+        char prbuf[PROJECT_BUFSZ], username[LOGNAME_MAX_ILLUMOS+1];
         struct project prj;
         char *tmp_name;
         struct passwd *pw = NULL;
 
         /*

@@ -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;