Date: Mon, 4 Mar 2019 03:30:40 +0000 (UTC) From: Andriy Voskoboinyk <avos@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344746 - in stable: 10/usr.sbin/rpc.ypupdated 11/usr.sbin/rpc.ypupdated 12/usr.sbin/rpc.ypupdated Message-ID: <201903040330.x243UeXn079274@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avos Date: Mon Mar 4 03:30:39 2019 New Revision: 344746 URL: https://svnweb.freebsd.org/changeset/base/344746 Log: MFC r344244: 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> Modified: stable/12/usr.sbin/rpc.ypupdated/update.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/10/usr.sbin/rpc.ypupdated/update.c stable/11/usr.sbin/rpc.ypupdated/update.c Directory Properties: stable/10/ (props changed) stable/11/ (props changed) Modified: stable/12/usr.sbin/rpc.ypupdated/update.c ============================================================================== --- stable/12/usr.sbin/rpc.ypupdated/update.c Mon Mar 4 03:02:14 2019 (r344745) +++ stable/12/usr.sbin/rpc.ypupdated/update.c Mon Mar 4 03:30:39 2019 (r344746) @@ -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?201903040330.x243UeXn079274>