don't need to explicitly NUL terminate strings written by snprintf()

This commit is contained in:
lukem 1996-11-22 05:34:06 +00:00
parent f6a82ef733
commit 8bcf7e5435
2 changed files with 2 additions and 11 deletions
usr.bin/finger

@ -36,7 +36,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)lprint.c 5.13 (Berkeley) 10/31/90";*/
static char rcsid[] = "$Id: lprint.c,v 1.5 1996/11/21 06:01:50 lukem Exp $";
static char rcsid[] = "$Id: lprint.c,v 1.6 1996/11/22 05:34:06 lukem Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -114,27 +114,23 @@ lprint(pn)
(void)snprintf(tbuf, sizeof(tbuf),
"%s: %s, %s", OFFICE_TAG, pn->office,
prphone(pn->officephone));
tbuf[sizeof(tbuf)-1] = '\0';
oddfield = demi_print(tbuf, oddfield);
} else {
if (pn->office) {
(void)snprintf(tbuf, sizeof(tbuf),
"%s: %s", OFFICE_TAG, pn->office);
tbuf[sizeof(tbuf)-1] = '\0';
oddfield = demi_print(tbuf, oddfield);
}
if (pn->officephone) {
(void)snprintf(tbuf, sizeof(tbuf),
"%s: %s", OFFICE_PHONE_TAG,
prphone(pn->officephone));
tbuf[sizeof(tbuf)-1] = '\0';
oddfield = demi_print(tbuf, oddfield);
}
}
if (pn->homephone) {
(void)snprintf(tbuf, sizeof(tbuf), "%s: %s", "Home Phone",
prphone(pn->homephone));
tbuf[sizeof(tbuf)-1] = '\0';
oddfield = demi_print(tbuf, oddfield);
}
if (oddfield)
@ -279,7 +275,6 @@ show_text(directory, file_name, header)
lastc = 0;
(void)snprintf(tbuf, sizeof(tbuf), "%s/%s", directory, file_name);
tbuf[sizeof(tbuf)-1] = '\0';
if ((fp = fopen(tbuf, "r")) == NULL)
return(0);
(void)printf("%s\n", header);

@ -37,7 +37,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)util.c 5.14 (Berkeley) 1/17/91";*/
static char rcsid[] = "$Id: util.c,v 1.7 1996/11/21 06:01:52 lukem Exp $";
static char rcsid[] = "$Id: util.c,v 1.8 1996/11/22 05:34:07 lukem Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -62,7 +62,6 @@ find_idle_and_ttywrite(w)
struct stat sb;
(void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_DEV, w->tty);
tbuf[sizeof(tbuf)-1] = '\0';
if (stat(tbuf, &sb) < 0) {
(void)fprintf(stderr,
"finger: %s: %s\n", tbuf, strerror(errno));
@ -91,7 +90,6 @@ userinfo(pn, pw)
pn->shell = strdup(pw->pw_shell);
(void)strncpy(bp = tbuf, pw->pw_gecos, sizeof(tbuf));
tbuf[sizeof(tbuf) - 1] = '\0';
/* ampersands get replaced by the login name */
if (!(p = strsep(&bp, ",")))
@ -106,7 +104,6 @@ userinfo(pn, pw)
strdup(p) : NULL;
(void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_MAILSPOOL,
pw->pw_name);
tbuf[sizeof(tbuf)-1] = '\0';
pn->mailrecv = -1; /* -1 == not_valid */
if (stat(tbuf, &sb) < 0) {
if (errno != ENOENT) {
@ -129,7 +126,6 @@ match(pw, user)
char name[1024];
(void)strncpy(p = tbuf, pw->pw_gecos, sizeof(tbuf));
tbuf[sizeof(tbuf) - 1] = '\0';
/* ampersands get replaced by the login name */
if (!(p = strtok(p, ",")))