bin/161510: commit references a PR

dfilter service dfilter at FreeBSD.ORG
Thu Jan 5 23:20:07 UTC 2012


The following reply was made to PR bin/161510; it has been noted by GNATS.

From: dfilter at FreeBSD.ORG (dfilter service)
To: bug-followup at FreeBSD.org
Cc:  
Subject: Re: bin/161510: commit references a PR
Date: Thu,  5 Jan 2012 23:10:18 +0000 (UTC)

 Author: ghelmer
 Date: Thu Jan  5 23:08:11 2012
 New Revision: 229668
 URL: http://svn.freebsd.org/changeset/base/229668
 
 Log:
   Fix a memory leak in addgroup() by ensuring the allocated memory
   is freed if an error occurs.
   
   PR:		bin/161510
   MFC after:	4 weeks
 
 Modified:
   head/usr.bin/newgrp/newgrp.c
 
 Modified: head/usr.bin/newgrp/newgrp.c
 ==============================================================================
 --- head/usr.bin/newgrp/newgrp.c	Thu Jan  5 22:48:36 2012	(r229667)
 +++ head/usr.bin/newgrp/newgrp.c	Thu Jan  5 23:08:11 2012	(r229668)
 @@ -190,7 +190,7 @@ addgroup(const char *grpname)
  		err(1, "malloc");
  	if ((ngrps = getgroups(ngrps_max, (gid_t *)grps)) < 0) {
  		warn("getgroups");
 -		return;
 +		goto end;
  	}
  
  	/* Remove requested gid from supp. list if it exists. */
 @@ -204,7 +204,7 @@ addgroup(const char *grpname)
  		if (setgroups(ngrps, (const gid_t *)grps) < 0) {
  			PRIV_END;
  			warn("setgroups");
 -			return;
 +			goto end;
  		}
  		PRIV_END;
  	}
 @@ -213,7 +213,7 @@ addgroup(const char *grpname)
  	if (setgid(grp->gr_gid)) {
  		PRIV_END;
  		warn("setgid");
 -		return;
 +		goto end;
  	}
  	PRIV_END;
  	grps[0] = grp->gr_gid;
 @@ -228,12 +228,12 @@ addgroup(const char *grpname)
  			if (setgroups(ngrps, (const gid_t *)grps)) {
  				PRIV_END;
  				warn("setgroups");
 -				return;
 +				goto end;
  			}
  			PRIV_END;
  		}
  	}
 -
 +end:
  	free(grps);
  }
  
 _______________________________________________
 svn-src-all at freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe at freebsd.org"
 


More information about the freebsd-bugs mailing list