From a3dc33654a3c5ec7f561ce557fbfa2fe5da9ad5e Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Tue, 13 Apr 2004 12:07:07 +0000 Subject: fix null pointer dereference when trying to read+clear non-existent memory log; spotted by mpech@ --- usr.sbin/syslogd/syslogd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index e92662e54c3..4ef7f6d51f0 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.74 2004/01/19 16:06:05 millert Exp $ */ +/* $OpenBSD: syslogd.c,v 1.75 2004/04/13 12:07:06 djm Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -39,7 +39,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94"; #else -static const char rcsid[] = "$OpenBSD: syslogd.c,v 1.74 2004/01/19 16:06:05 millert Exp $"; +static const char rcsid[] = "$OpenBSD: syslogd.c,v 1.75 2004/04/13 12:07:06 djm Exp $"; #endif #endif /* not lint */ @@ -1660,11 +1660,10 @@ ctlconn_read_handler(void) } else { ringbuf_to_string(ctl_reply, MAX_MEMBUF, f->f_un.f_mb.f_rb); + if (ctl_cmd.cmd == CMD_READ_CLEAR) + ringbuf_clear(f->f_un.f_mb.f_rb); } ctl_reply_size = strlen(ctl_reply); - - if (ctl_cmd.cmd == CMD_READ_CLEAR) - ringbuf_clear(f->f_un.f_mb.f_rb); break; case CMD_CLEAR: f = find_membuf_log(ctl_cmd.logname); -- cgit v1.2.3