summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorcwt <cwt@FreeBSD.org>1998-12-29 23:14:50 +0000
committercwt <cwt@FreeBSD.org>1998-12-29 23:14:50 +0000
commit233301419faa6f8b8f82b8b78115e7c72080ee01 (patch)
treea943e74eec53c5e451ba05a0845181487ebde9d5 /usr.sbin
parent065be558704c9254fa782e3c7a9c5496ff74c61c (diff)
downloadFreeBSD-src-233301419faa6f8b8f82b8b78115e7c72080ee01.zip
FreeBSD-src-233301419faa6f8b8f82b8b78115e7c72080ee01.tar.gz
Ensure a terminating null when processing hostname strings from
arbitrary sources. Obtained from: OpenBSD
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/syslogd/syslogd.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index f8e9aef..523de1a 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
#endif
static const char rcsid[] =
- "$Id: syslogd.c,v 1.44 1998/12/28 00:39:14 cwt Exp $";
+ "$Id: syslogd.c,v 1.45 1998/12/29 20:36:22 cwt Exp $";
#endif /* not lint */
/*
@@ -741,7 +741,8 @@ logmsg(pri, msg, from, flags)
f->f_prevpri = pri;
(void)strncpy(f->f_lasttime, timestamp, 15);
(void)strncpy(f->f_prevhost, from,
- sizeof(f->f_prevhost));
+ sizeof(f->f_prevhost)-1);
+ f->f_prevhost[sizeof(f->f_prevhost)-1] = '\0';
if (msglen < MAXSVLINE) {
f->f_prevlen = msglen;
(void)strcpy(f->f_prevline, msg);
@@ -1466,8 +1467,10 @@ cfline(line, f, prog)
switch (*p)
{
case '@':
- (void)strcpy(f->f_un.f_forw.f_hname, ++p);
- hp = gethostbyname(p);
+ (void)strncpy(f->f_un.f_forw.f_hname, ++p,
+ sizeof(f->f_un.f_forw.f_hname)-1);
+ f->f_un.f_forw.f_hname[sizeof(f->f_un.f_forw.f_hname)-1] = '\0';
+ hp = gethostbyname(f->f_un.f_forw.f_hname);
if (hp == NULL) {
extern int h_errno;
OpenPOWER on IntegriCloud