1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

Use snprintf() instead of sprintf() most of the time.

Obtained from: OpenBSD

Make usage() consistent with man page.
This commit is contained in:
Brian Somers 1997-09-19 22:22:04 +00:00
parent 99352561f6
commit 173471e627
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29623
2 changed files with 13 additions and 13 deletions

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93
.\" $Id: syslogd.8,v 1.10 1997/04/29 09:09:40 jmg Exp $
.\" $Id: syslogd.8,v 1.11 1997/05/03 22:17:43 joerg Exp $
.\"
.Dd October 12, 1995
.Dt SYSLOGD 8
@ -40,11 +40,11 @@
.Nd log systems messages
.Sh SYNOPSIS
.Nm
.Op Fl ds
.Op Fl a Ar allowed_peer
.Op Fl f Ar config_file
.Op Fl m Ar mark_interval
.Op Fl p Ar log_socket
.Op Fl s
.Sh DESCRIPTION
The
.Nm

View File

@ -39,7 +39,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
*/
static const char rcsid[] =
"$Id: syslogd.c,v 1.24 1997/04/26 00:03:21 pst Exp $";
"$Id: syslogd.c,v 1.25 1997/05/03 22:17:43 joerg Exp $";
#endif /* not lint */
/*
@ -354,7 +354,7 @@ main(argc, argv)
if (funix < 0 ||
bind(funix, (struct sockaddr *)&sunx, SUN_LEN(&sunx)) < 0 ||
chmod(LogName, 0666) < 0) {
(void) sprintf(line, "cannot create %s", LogName);
(void) snprintf(line, sizeof line, "cannot create %s", LogName);
logerror(line);
dprintf("cannot create %s (%d)\n", LogName, errno);
die(0);
@ -469,8 +469,8 @@ usage()
{
fprintf(stderr,
"usage: syslogd [-ds] [-f conffile] [-m markinterval]"
" [-p logpath] [-a allowaddr]\n");
"usage: syslogd [-ds] [-a allowed_peer] [-f config_file]"
" [-m mark_interval]\n [-p log_socket]\n");
exit(1);
}
@ -710,7 +710,7 @@ fprintlog(f, flags, msg)
v = iov;
if (f->f_type == F_WALL) {
v->iov_base = greetings;
v->iov_len = sprintf(greetings,
v->iov_len = snprintf(greetings, sizeof greetings,
"\r\n\7Message from syslogd@%s at %.24s ...\r\n",
f->f_prevhost, ctime(&now));
v++;
@ -755,8 +755,8 @@ fprintlog(f, flags, msg)
case F_FORW:
dprintf(" %s\n", f->f_un.f_forw.f_hname);
l = sprintf(line, "<%d>%.15s %s", f->f_prevpri,
iov[0].iov_base, iov[4].iov_base);
l = snprintf(line, sizeof line - 1, "<%d>%.15s %s",
f->f_prevpri, iov[0].iov_base, iov[4].iov_base);
if (l > MAXLINE)
l = MAXLINE;
if ((finet >= 0) &&
@ -1035,9 +1035,9 @@ logerror(type)
if (errno)
(void)snprintf(buf,
sizeof(buf), "syslogd: %s: %s", type, strerror(errno));
sizeof buf, "syslogd: %s: %s", type, strerror(errno));
else
(void)snprintf(buf, sizeof(buf), "syslogd: %s", type);
(void)snprintf(buf, sizeof buf, "syslogd: %s", type);
errno = 0;
dprintf("%s\n", buf);
logmsg(LOG_SYSLOG|LOG_ERR, buf, LocalHostName, ADDDATE);
@ -1274,7 +1274,7 @@ cfline(line, f, prog)
else {
pri = decode(buf, prioritynames);
if (pri < 0) {
(void)sprintf(ebuf,
(void)snprintf(ebuf, sizeof ebuf,
"unknown priority name \"%s\"", buf);
logerror(ebuf);
return;
@ -1292,7 +1292,7 @@ cfline(line, f, prog)
else {
i = decode(buf, facilitynames);
if (i < 0) {
(void)sprintf(ebuf,
(void)snprintf(ebuf, sizeof ebuf,
"unknown facility name \"%s\"",
buf);
logerror(ebuf);