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>
@@ -44,10 +44,16 @@
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <priv_utils.h>
+#ifdef LOGNAME_MAX_ILLUMOS
+#define _LOGNAME_MAX LOGNAME_MAX_ILLUMOS
+#else /* LOGNAME_MAX_ILLUMOS */
+#define _LOGNAME_MAX LOGNAME_MAX
+#endif /* LOGNAME_MAX_ILLUMOS */
+
#include "utils.h"
#define OPTIONS_STRING "Fc:lp:v"
#define NENV 8
#define ENVSIZE 255
@@ -652,11 +658,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+1];
struct project prj;
char *tmp_name;
struct passwd *pw = NULL;
/*
@@ -694,11 +700,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;