From owner-freebsd-bugs@FreeBSD.ORG Wed Oct 12 00:20:04 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B80F106564A for ; Wed, 12 Oct 2011 00:20:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 3F5E08FC15 for ; Wed, 12 Oct 2011 00:20:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p9C0K412035723 for ; Wed, 12 Oct 2011 00:20:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p9C0K4n2035722; Wed, 12 Oct 2011 00:20:04 GMT (envelope-from gnats) Resent-Date: Wed, 12 Oct 2011 00:20:04 GMT Resent-Message-Id: <201110120020.p9C0K4n2035722@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jeremy Huddleston Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28498106566C for ; Wed, 12 Oct 2011 00:14:18 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 18A1F8FC15 for ; Wed, 12 Oct 2011 00:14:18 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p9C0EHkS020269 for ; Wed, 12 Oct 2011 00:14:17 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p9C0EH5N020241; Wed, 12 Oct 2011 00:14:17 GMT (envelope-from nobody) Message-Id: <201110120014.p9C0EH5N020241@red.freebsd.org> Date: Wed, 12 Oct 2011 00:14:17 GMT From: Jeremy Huddleston To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/161510: usr.bin/newgrp has a memory leak X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2011 00:20:04 -0000 >Number: 161510 >Category: misc >Synopsis: usr.bin/newgrp has a memory leak >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Oct 12 00:20:03 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Jeremy Huddleston >Release: HEAD >Organization: Apple Inc >Environment: NA >Description: version 1.3 added support for variable _SC_NGROUPS_MAX by mallocing the array, but the array is not freed on errors. >How-To-Repeat: >Fix: Index: newgrp.c =================================================================== --- newgrp.c (revision 3271) +++ newgrp.c (working copy) @@ -217,7 +217,7 @@ 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. */ @@ -231,7 +231,7 @@ if (setgroups(ngrps, (const gid_t *)grps) < 0) { PRIV_END; warn("setgroups"); - return; + goto end; } PRIV_END; } @@ -240,7 +240,7 @@ if (setgid(grp->gr_gid)) { PRIV_END; warn("setgid"); - return; + goto end; } PRIV_END; grps[0] = grp->gr_gid; @@ -255,12 +255,13 @@ if (setgroups(ngrps, (const gid_t *)grps)) { PRIV_END; warn("setgroups"); - return; + goto end; } PRIV_END; } } +end: free(grps); } >Release-Note: >Audit-Trail: >Unformatted: