From owner-freebsd-bugs@FreeBSD.ORG Sun Nov 15 16:25:34 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 A2C42106566C for ; Sun, 15 Nov 2009 16:25:34 +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 3EC418FC14 for ; Sun, 15 Nov 2009 16:25:33 +0000 (UTC) Received: by fxm27 with SMTP id 27so5194749fxm.3 for ; Sun, 15 Nov 2009 08:25:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=Jb9pu+c0z5ePH+LLGobTKP094sBzB3xsIcAW7mtC0Z8=; b=Kg9M9nG0fAJnO7MXiaLBbL82Ot3mPl5MMycmDv+3zIBoc8F5b9+SNLdA6R/uqa4MLx quGwoCvpnSUBc9vmVevsqSa9tGaNp+MBdwk5wxZGdTjiNrx9pjf7hpchrgitJqe9kNqL NaDkRTbHGEb35E2I0b7BhKnSOCfDnwBN+6Rig= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=w/dOfo8DfuvHSayy9nKudBvleAwxnpIvHJbU6h0cONlmGnXCfbWewWZqpLge4Pie/W TMXygn8muvl+cxZ/wIgI8/EEa76wRtHzpAngO6VS4CPVhO5bFH6HWVS1wLrs4GrQF9Nt 54p4JQsZbrMbfaiysEcLDVl/hwoWSPIR9VLAE= MIME-Version: 1.0 Received: by 10.223.4.27 with SMTP id 27mr968075fap.48.1258301060011; Sun, 15 Nov 2009 08:04:20 -0800 (PST) Date: Sun, 15 Nov 2009 11:04:19 -0500 Message-ID: From: Jim Wilcoxson To: freebsd-bugs@freebsd.org, testing@lists.pcbsd.org Content-Type: text/plain; charset=ISO-8859-1 Cc: Subject: 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: Sun, 15 Nov 2009 16:25:34 -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