From owner-freebsd-hackers@FreeBSD.ORG Sun Nov 15 17:20:27 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF75B1065676 for ; Sun, 15 Nov 2009 17:20:27 +0000 (UTC) (envelope-from prirun@gmail.com) Received: from mail-fx0-f227.google.com (mail-fx0-f227.google.com [209.85.220.227]) by mx1.freebsd.org (Postfix) with ESMTP id 46E6C8FC15 for ; Sun, 15 Nov 2009 17:20:27 +0000 (UTC) Received: by fxm27 with SMTP id 27so5226710fxm.3 for ; Sun, 15 Nov 2009 09:20:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=Jb9pu+c0z5ePH+LLGobTKP094sBzB3xsIcAW7mtC0Z8=; b=NrjJ9IwaGCZ8hXXubHuZHnTjR56jdZmi6eaYgS5tLCX0Fa/iWhFOBuzSvR766mlglV ZFFCSJdyKFw+0f4dFM3451YGxwSboKwUKPEWddBAB7d3XFqahVdWcVh7CITRV+n6VjbN r24aSfha8uTLKHwK8nRuZWhZotfSbTilDQTq0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=f442j2KnvPtskBF39CO1lwZ7U3TV23wXm8b76lsfuoRu8eccVhmar/Ls0+D5CctAAB sTa5HreI4TNIR7U1TYGUtzunQcz6IVBwswBcQXMGmnmS3d+oEslUKKZd0yP9rZPwICKH tqSWZCh28wqDovvmkjbAoNKFYl/NgDTcAZOkY= MIME-Version: 1.0 Received: by 10.223.29.193 with SMTP id r1mr1031792fac.29.1258303648687; Sun, 15 Nov 2009 08:47:28 -0800 (PST) In-Reply-To: References: Date: Sun, 15 Nov 2009 11:47:28 -0500 Message-ID: From: Jim Wilcoxson To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: acl_from_text leaking memory X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2009 17:20:27 -0000 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). 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. 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: } #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) == -1) { errno = EINVAL; goto error_label; } #endif return(acl); error_label: acl_free(acl); free(mybuf_p); return(NULL); } I think there should be a free(mybuf_p) before return(acl). Here is a PCBSD/FreeBSD test program that causes the memory leak: #include #include #include main() { acl_t acl; char* acltext; acltext = "user::rw-\n group::r--\n mask::r--\n other::r--\n"; while (1) { acl = acl_from_text(acltext); if (acl == NULL) printf("acl_from_text failed\n"); if (acl_free(acl) != 0) printf("acl_free failed\n"); } } I've subscribed to the lists for a few days in case there are questions or I can help test something. Thanks, Jim -- HashBackup beta: http://sites.google.com/site/hashbackup