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 <dcb...@hotmail.com> Modified: stable/10/usr.sbin/rpc.ypupdated/update.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/usr.sbin/rpc.ypupdated/update.c stable/12/usr.sbin/rpc.ypupdated/update.c Directory Properties: stable/11/ (props changed) stable/12/ (props changed) Modified: stable/10/usr.sbin/rpc.ypupdated/update.c ============================================================================== --- stable/10/usr.sbin/rpc.ypupdated/update.c Mon Mar 4 03:02:14 2019 (r344745) +++ stable/10/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); } _______________________________________________ svn-src-stable-10@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10 To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"