svn commit: r344746 - in stable: 10/usr.sbin/rpc.ypupdated 11/usr.sbin/rpc.ypupdated 12/usr.sbin/rpc.ypupdated
Andriy Voskoboinyk
avos at FreeBSD.org
Mon Mar 4 03:30:41 UTC 2019
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 at 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);
}
More information about the svn-src-stable
mailing list