From owner-svn-src-head@freebsd.org Mon Feb 26 19:28:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C346F3CECD; Mon, 26 Feb 2018 19:28:00 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C41A18511E; Mon, 26 Feb 2018 19:27:59 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEF611FA8B; Mon, 26 Feb 2018 19:27:59 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1QJRxsv030489; Mon, 26 Feb 2018 19:27:59 GMT (envelope-from dab@FreeBSD.org) Received: (from dab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1QJRx94030488; Mon, 26 Feb 2018 19:27:59 GMT (envelope-from dab@FreeBSD.org) Message-Id: <201802261927.w1QJRx94030488@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dab set sender to dab@FreeBSD.org using -f From: David Bright Date: Mon, 26 Feb 2018 19:27:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330034 - head/usr.sbin/syslogd X-SVN-Group: head X-SVN-Commit-Author: dab X-SVN-Commit-Paths: head/usr.sbin/syslogd X-SVN-Commit-Revision: 330034 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Feb 2018 19:28:00 -0000 Author: dab Date: Mon Feb 26 19:27:59 2018 New Revision: 330034 URL: https://svnweb.freebsd.org/changeset/base/330034 Log: Fix two memory leaks in syslogd A memory leak in syslogd for processing of forward actions was reported. This modification adapts the patch submitted with that bug to fix the leak. While testing the modification, another leak was also found and fixed. PR: 198385 Submitted by: Sreeram Reported by: Sreeram Reviewed by: hrs MFC after: 1 week Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D14510 Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Mon Feb 26 19:26:59 2018 (r330033) +++ head/usr.sbin/syslogd/syslogd.c Mon Feb 26 19:27:59 2018 (r330034) @@ -180,7 +180,7 @@ static STAILQ_HEAD(, socklist) shead = STAILQ_HEAD_INI * This structure represents the files that will have log * copies printed. * We require f_file to be valid if f_type is F_FILE, F_CONSOLE, F_TTY - * or if f_type if F_PIPE and f_pid > 0. + * or if f_type is F_PIPE and f_pid > 0. */ struct filed { @@ -382,10 +382,16 @@ close_filed(struct filed *f) return; switch (f->f_type) { - case F_FILE: + case F_FORW: + if (f->f_un.f_forw.f_addr) { + freeaddrinfo(f->f_un.f_forw.f_addr); + f->f_un.f_forw.f_addr = NULL; + } + /*FALLTHROUGH*/ + + case F_FILE: case F_TTY: case F_CONSOLE: - case F_FORW: f->f_type = F_UNUSED; break; case F_PIPE: @@ -1859,6 +1865,7 @@ readconfigfile(FILE *cf, int allow_includes) f = cfline(cline, prog, host); if (f != NULL) addfile(f); + free(f); } } @@ -1956,9 +1963,11 @@ init(int signo) f = cfline("*.ERR\t/dev/console", "*", "*"); if (f != NULL) addfile(f); + free(f); f = cfline("*.PANIC\t*", "*", "*"); if (f != NULL) addfile(f); + free(f); Initialized = 1; return;