strlcpy (buf, optarg, strlen (optarg) + 1);
strlcpy (buf, optarg, sizeof(buf));
useradd(int argc, char **argv){	user_t	u;	int	defaultfield;	int	bigD;	int	c;	int	i;	char    buf[MaxEntryLen], *s, *p;	(void) memset(&u, 0, sizeof(u));	read_defaults(&u);	u.u_uid = -1;	defaultfield = bigD = 0;	while ((c = getopt(argc, argv, "DG:b:c:d:e:f:g:k:mou:s:" ADD_OPT_EXTENSIONS)) != -1) {		switch(c) {		case 'D':			bigD = 1;			break;		case 'G':		        strlcpy (buf, optarg, strlen (optarg) + 1);			p = buf;			while ((s = strsep (&p, ",")) != NULL &&			       u.u_groupc < NGROUPS_MAX - 2)			  	memsave (&u.u_groupv[u.u_groupc++], s, 					 strlen(s));			if (p != NULL)			  	errx(EXIT_FAILURE, "too many groups for -G");			break;		case 'b':			defaultfield = 1;			memsave(&u.u_basedir, optarg, strlen(optarg));			break;		case 'c':			memsave(&u.u_comment, optarg, strlen(optarg));			break;		case 'd':			u.u_homeset = 1;			memsave(&u.u_home, optarg, strlen(optarg));			break;		case 'e':			defaultfield = 1;			memsave(&u.u_expire, optarg, strlen(optarg));			break;		case 'f':			defaultfield = 1;			u.u_inactive = atoi(optarg);			break;		case 'g':			defaultfield = 1;			memsave(&u.u_primgrp, optarg, strlen(optarg));			break;		case 'k':			memsave(&u.u_skeldir, optarg, strlen(optarg));			break;		case 'm':			u.u_mkdir = 1;			break;		case 'o':			u.u_dupuid = 1;			break;#ifdef EXTENSIONS		case 'p':			memsave(&u.u_password, optarg, strlen(optarg));			break;#endif#ifdef EXTENSIONS		case 'r':			defaultfield = 1;			(void) save_range(&u, optarg);			break;#endif		case 's':			defaultfield = 1;			memsave(&u.u_shell, optarg, strlen(optarg));			break;		case 'u':			if (!is_number(optarg)) {				errx(EXIT_FAILURE, "When using [-u uid], the uid must be numeric");			}			u.u_uid = atoi(optarg);			break;#ifdef EXTENSIONS		case 'v':			verbose = 1;			break;#endif		}	}	if (bigD) {		if (defaultfield) {			checkeuid();			return setdefaults(&u) ? EXIT_SUCCESS : EXIT_FAILURE;		}		(void) printf("group\t\t%s\n", u.u_primgrp);		(void) printf("base_dir\t%s\n", u.u_basedir);		(void) printf("skel_dir\t%s\n", u.u_skeldir);		(void) printf("shell\t\t%s\n", u.u_shell);		(void) printf("inactive\t%d\n", u.u_inactive);		(void) printf("expire\t\t%s\n", (u.u_expire == NULL) ? UNSET_EXPIRY : u.u_expire);#ifdef EXTENSIONS		for (i = 0 ; i < u.u_rc ; i++) {			(void) printf("range\t\t%d..%d\n", u.u_rv[i].r_from, u.u_rv[i].r_to);		}#endif		return EXIT_SUCCESS;	}	if (argc == optind) {		usermgmt_usage("useradd");	}	checkeuid();	return adduser(argv[optind], &u) ? EXIT_SUCCESS : EXIT_FAILURE;}