Date: Mon, 18 Feb 2019 03:15:25 +0000 (UTC) From: Andriy Voskoboinyk <avos@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r344244 - head/usr.sbin/rpc.ypupdated Message-ID: <201902180315.x1I3FPkD077890@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avos Date: Mon Feb 18 03:15:25 2019 New Revision: 344244 URL: https://svnweb.freebsd.org/changeset/base/344244 Log: Fix memory / resource leaks in usr.sbin/rpc.ypupdated/update.c Re-apply r343909 to this file to get the issue fixed. PR: 204956 Reported by: David Binderman <dcb314@hotmail.com> MFC after: 5 days Modified: head/usr.sbin/rpc.ypupdated/update.c Modified: head/usr.sbin/rpc.ypupdated/update.c ============================================================================== --- head/usr.sbin/rpc.ypupdated/update.c Mon Feb 18 02:59:47 2019 (r344243) +++ head/usr.sbin/rpc.ypupdated/update.c Mon Feb 18 03:15:25 2019 (r344244) @@ -263,11 +263,14 @@ localupdate(char *name, char *filename, u_int op, u_in sprintf(tmpname, "%s.tmp", filename); rf = fopen(filename, "r"); if (rf == NULL) { - return (ERR_READ); + err = ERR_READ; + goto cleanup; } wf = fopen(tmpname, "w"); if (wf == NULL) { - return (ERR_WRITE); + fclose(rf); + err = ERR_WRITE; + goto cleanup; } err = -1; while (fgets(line, sizeof (line), rf)) { @@ -307,13 +310,17 @@ localupdate(char *name, char *filename, u_int op, u_in fclose(rf); if (err == 0) { if (rename(tmpname, filename) < 0) { - return (ERR_DBASE); + err = ERR_DBASE; + goto cleanup; } } else { if (unlink(tmpname) < 0) { - return (ERR_DBASE); + err = ERR_DBASE; + goto cleanup; } } +cleanup: + free(tmpname); return (err); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902180315.x1I3FPkD077890>