if (snprintf(cp, len, " %s", user[i]) > len) {
if (snprintf(cp, len, " %s", user[i]) >= len) {
displayq(format)	int format;{	register struct queue *q;	register int i, nitems, fd, ret, len;	register char	*cp;	struct queue **queue;	struct stat statb;	FILE *fp;	lflag = format;	totsize = 0;	rank = -1;	if ((i = cgetent(&bp, printcapdb, printer)) == -2)		fatal("can't open printer description file");	else if (i == -1)		fatal("unknown printer");	else if (i == -3)		fatal("potential reference loop detected in printcap file");	if (cgetstr(bp, "lp", &LP) < 0)		LP = _PATH_DEFDEVLP;	if (cgetstr(bp, "rp", &RP) < 0)		RP = DEFLP;	if (cgetstr(bp, "sd", &SD) < 0)		SD = _PATH_DEFSPOOL;	if (cgetstr(bp,"lo", &LO) < 0)		LO = DEFLOCK;	if (cgetstr(bp, "st", &ST) < 0)		ST = DEFSTAT;	cgetstr(bp, "rm", &RM);	if ((cp = checkremote()))		printf("Warning: %s\n", cp);	/*	 * Print out local queue	 * Find all the control files in the spooling directory	 */	seteuid(euid);	if (chdir(SD) < 0)		fatal("cannot chdir to spooling directory");	seteuid(uid);	if ((nitems = getq(&queue)) < 0)		fatal("cannot examine spooling area\n");	seteuid(euid);	ret = stat(LO, &statb);	seteuid(uid);	if (ret >= 0) {		if (statb.st_mode & 0100) {			if (remote)				printf("%s: ", host);			printf("Warning: %s is down: ", printer);			seteuid(euid);			fd = open(ST, O_RDONLY);			seteuid(uid);			if (fd >= 0) {				(void) flock(fd, LOCK_SH);				while ((i = read(fd, line, sizeof(line))) > 0)					(void) fwrite(line, 1, i, stdout);				(void) close(fd);	/* unlocks as well */			} else				putchar('\n');		}		if (statb.st_mode & 010) {			if (remote)				printf("%s: ", host);			printf("Warning: %s queue is turned off\n", printer);		}	}	if (nitems) {		seteuid(euid);		fp = fopen(LO, "r");		seteuid(uid);		if (fp == NULL)			warn();		else {			/* get daemon pid */			cp = current;			while ((i = getc(fp)) != EOF && i != '\n')				*cp++ = i;			*cp = '\0';			i = atoi(current);			if (i <= 0) {				ret = -1;			} else {				seteuid(euid);				ret = kill(i, 0);				seteuid(uid);			}			if (ret < 0) {				warn();			} else {				/* read current file name */				cp = current;				while ((i = getc(fp)) != EOF && i != '\n')					*cp++ = i;				*cp = '\0';				/*				 * Print the status file.				 */				if (remote)					printf("%s: ", host);				seteuid(euid);				fd = open(ST, O_RDONLY);				seteuid(uid);				if (fd >= 0) {					(void) flock(fd, LOCK_SH);					while ((i = read(fd, line, sizeof(line))) > 0)						(void) fwrite(line, 1, i, stdout);					(void) close(fd);	/* unlocks as well */				} else					putchar('\n');			}			(void) fclose(fp);		}		/*		 * Now, examine the control files and print out the jobs to		 * be done for each user.		 */		if (!lflag)			header();		for (i = 0; i < nitems; i++) {			q = queue[i];			inform(q->q_name);			free(q);		}		free(queue);	}	if (!remote) {		if (nitems == 0)			puts("no entries");		return;	}	/*	 * Print foreign queue	 * Note that a file in transit may show up in either queue.	 */	if (nitems)		putchar('\n');	(void) snprintf(line, sizeof line, "%c%s", format + '\3', RP);	cp = line;	cp += strlen(cp);	for (i = 0; i < requests && cp-line < sizeof(line) - 1; i++) {		len = line + sizeof line - cp;		if (snprintf(cp, len, " %d", requ[i]) > len) {			cp += strlen(cp);			break;		}		cp += strlen(cp);	}	for (i = 0; i < users && cp-line < sizeof(line) - 1; i++) {		len = line + sizeof line - cp;		if (snprintf(cp, len, " %s", user[i]) > len) {			cp += strlen(cp);			break;		}	}	if (cp-line < sizeof(line) - 1) {		strcat(line, "\n");	} else {		line[sizeof line-2] = '\n';	}	fd = getport(RM, 0);	if (fd < 0) {		if (from != host)			printf("%s: ", host);		printf("connection to %s is down\n", RM);	}	else {		i = strlen(line);		if (write(fd, line, i) != i)			fatal("Lost connection");		while ((i = read(fd, line, sizeof(line))) > 0)			(void) fwrite(line, 1, i, stdout);		(void) close(fd);	}}