From owner-freebsd-bugs@FreeBSD.ORG Mon Nov 16 09:43:06 2009 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C50B61065672 for ; Mon, 16 Nov 2009 09:43:06 +0000 (UTC) (envelope-from chris@brueffer.de) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.8]) by mx1.freebsd.org (Postfix) with ESMTP id 6E9B58FC1A for ; Mon, 16 Nov 2009 09:43:06 +0000 (UTC) Received: from brueffer.de (host1.allnav.ch [212.55.212.50]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0MQM9c-1NdlKQ45hE-00UJBv; Mon, 16 Nov 2009 10:30:19 +0100 Received: by brueffer.de (Postfix, from userid 1001) id 767F917024; Mon, 16 Nov 2009 10:30:09 +0100 (CET) Date: Mon, 16 Nov 2009 10:30:09 +0100 From: Christian Brueffer To: Jim Wilcoxson Message-ID: <20091116093008.GB1459@serenity> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pWyiEgJYm5f9v55/" Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 9.0-CURRENT X-PGP-Key: http://people.FreeBSD.org/~brueffer/brueffer.key.asc X-PGP-Fingerprint: A5C8 2099 19FF AACA F41B B29B 6C76 178C A0ED 982D User-Agent: Mutt/1.5.19 (2009-01-05) X-Provags-ID: V01U2FsdGVkX1+GPH8vQyuxx0UjYnKglgAx1FYKcVKSYMAJfLE 3jex07t8/Hken8TsIkabdWhTxqVNasFTH96fH/9rFI6w6OkJkv 8DYt2X8bXg5SIprnUldqXH2CioONrFo Cc: freebsd-bugs@freebsd.org, testing@lists.pcbsd.org Subject: Re: acl_from_text leaking memory 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: Mon, 16 Nov 2009 09:43:06 -0000 --pWyiEgJYm5f9v55/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Nov 15, 2009 at 11:04:19AM -0500, Jim Wilcoxson wrote: > I've been working on a new backup program, HashBackup, and believe I > have found a memory leak with ACLs in PCBSD/FreeBSD 7.1 and OSX > (Leopard). >=20 > acl_from_text is a function that takes a text string as input, and > returns a pointer to a malloc'd acl. This acl is then freed with > acl_free. I noticed that acl_from_text appears to leak memory. This > is not used during the backup of a filesystem, but is needed to do a > restore. >=20 > After looking at the acl_from_text source in /usr/src/lib/libc/posix1e > (from PCBSD7.1), I believe the problem is that the duplicate text > string, mybuf_p, is not freed on normal return of this function. Here > is the end of this function: >=20 > } >=20 > #if 0 > /* XXX Should we only return ACLs valid according to acl_valid? */ > /* Verify validity of the ACL we read in. */ > if (acl_valid(acl) =3D=3D -1) { > errno =3D EINVAL; > goto error_label; > } > #endif >=20 > return(acl); >=20 > error_label: > acl_free(acl); > free(mybuf_p); > return(NULL); > } >=20 > I think there should be a free(mybuf_p) before return(acl). >=20 > Here is a PCBSD/FreeBSD test program that causes the memory leak: >=20 > #include > #include > #include >=20 > main() { > acl_t acl; > char* acltext; >=20 > acltext =3D "user::rw-\n group::r--\n mask::r--\n other::r--\n"; > while (1) { > acl =3D acl_from_text(acltext); > if (acl =3D=3D NULL) > printf("acl_from_text failed\n"); > if (acl_free(acl) !=3D 0) > printf("acl_free failed\n"); > } > } >=20 > I've subscribed to the lists for a few days in case there are > questions or I can help test something. >=20 Hi Jim, this looks good, I`ve just committed it to HEAD. I will merge it to the stable branches next week. Thanks for the submission! - Christian --=20 Christian Brueffer chris@unixpages.org brueffer@FreeBSD.org GPG Key: http://people.freebsd.org/~brueffer/brueffer.key.asc GPG Fingerprint: A5C8 2099 19FF AACA F41B B29B 6C76 178C A0ED 982D --pWyiEgJYm5f9v55/ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAksBG6AACgkQbHYXjKDtmC2nIgCfbL2meL4DiA1moZl9f5cnL8VZ zasAoKngKM/90ry+MoyooNAPJeRhHMtY =10U9 -----END PGP SIGNATURE----- --pWyiEgJYm5f9v55/--