Date: Mon, 23 May 2016 04:47:24 +0000 (UTC) From: Don Lewis <truckman@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r300449 - stable/10/usr.sbin/config Message-ID: <201605230447.u4N4lOpg074958@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: truckman Date: Mon May 23 04:47:24 2016 New Revision: 300449 URL: https://svnweb.freebsd.org/changeset/base/300449 Log: MFC r299893 Don't free fnamebuf before we calling cfgfile_add(). This changes a use-after-free error into a minor memory leak. Reported by: Coverity CID: 1006084 Modified: stable/10/usr.sbin/config/lang.l Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/config/lang.l ============================================================================== --- stable/10/usr.sbin/config/lang.l Mon May 23 04:17:27 2016 (r300448) +++ stable/10/usr.sbin/config/lang.l Mon May 23 04:47:24 2016 (r300449) @@ -267,7 +267,8 @@ include(const char *fname, int ateof) asprintf(&fnamebuf, "../../conf/%s", fname); if (fnamebuf != NULL) { fp = fopen(fnamebuf, "r"); - free(fnamebuf); + if (fp == NULL) + free(fnamebuf); } } if (fp == NULL) { @@ -275,10 +276,10 @@ include(const char *fname, int ateof) asprintf(&fnamebuf, "%s/%s", ipath->path, fname); if (fnamebuf != NULL) { fp = fopen(fnamebuf, "r"); - free(fnamebuf); } if (fp != NULL) break; + free(fnamebuf); } } if (fp == NULL) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605230447.u4N4lOpg074958>