Bug 204956

Summary: usr/src/usr.sbin/rpc.ypupdated/update.c:270: resource leak
Product: Base System Reporter: David Binderman <dcb314>
Component: miscAssignee: Andriy Voskoboinyk <avos>
Status: Closed FIXED    
Severity: Affects Some People CC: avos, pfg
Priority: --- Flags: avos: mfc-stable12+
avos: mfc-stable11+
avos: mfc-stable10+
Version: CURRENT   
Hardware: Any   
OS: Any   

Description David Binderman 2015-12-02 08:45:16 UTC
[usr/src/usr.sbin/rpc.ypupdated/update.c:270]: (error) Resource leak: rf

    rf = fopen(filename, "r");
    if (rf == NULL) {
        return (ERR_READ);
    }
    wf = fopen(tmpname, "w");
    if (wf == NULL) {
        return (ERR_WRITE);
    }
Comment 1 Pedro F. Giffuni freebsd_committer freebsd_triage 2017-11-04 20:33:01 UTC
Confirmed by Coverity:

CID 1007425 (#1 of 1): Resource leak (RESOURCE_LEAK)
8. leaked_storage: Variable rf going out of scope leaks the storage it points to.
Comment 2 commit-hook freebsd_committer freebsd_triage 2019-02-18 03:16:29 UTC
A commit references this bug:

Author: avos
Date: Mon Feb 18 03:15:25 UTC 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

Changes:
  head/usr.sbin/rpc.ypupdated/update.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-03-04 03:31:01 UTC
A commit references this bug:

Author: avos
Date: Mon Mar  4 03:30:40 UTC 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>

Changes:
_U  stable/10/
  stable/10/usr.sbin/rpc.ypupdated/update.c
_U  stable/11/
  stable/11/usr.sbin/rpc.ypupdated/update.c
_U  stable/12/
  stable/12/usr.sbin/rpc.ypupdated/update.c