From owner-freebsd-bugs@FreeBSD.ORG Mon Mar 15 21:00:36 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BE3B216A4D1 for ; Mon, 15 Mar 2004 21:00:36 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7CA3543D1F for ; Mon, 15 Mar 2004 21:00:31 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i2G50Vbv029926 for ; Mon, 15 Mar 2004 21:00:31 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i2G50VQg029924; Mon, 15 Mar 2004 21:00:31 -0800 (PST) (envelope-from gnats) Resent-Date: Mon, 15 Mar 2004 21:00:31 -0800 (PST) Resent-Message-Id: <200403160500.i2G50VQg029924@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, Rodney Ruddock Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2A00016A4CE for ; Mon, 15 Mar 2004 20:51:13 -0800 (PST) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2350243D2F for ; Mon, 15 Mar 2004 20:51:13 -0800 (PST) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i2G4pC72096960 for ; Mon, 15 Mar 2004 20:51:12 -0800 (PST) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.10/8.12.10/Submit) id i2G4pCtA096959; Mon, 15 Mar 2004 20:51:12 -0800 (PST) (envelope-from nobody) Message-Id: <200403160451.i2G4pCtA096959@www.freebsd.org> Date: Mon, 15 Mar 2004 20:51:12 -0800 (PST) From: Rodney Ruddock To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: bin/64321: pax cacheing bug X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Mar 2004 05:00:36 -0000 >Number: 64321 >Category: bin >Synopsis: pax cacheing bug >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 15 21:00:31 PST 2004 >Closed-Date: >Last-Modified: >Originator: Rodney Ruddock >Release: none >Organization: Interop Systems >Environment: none >Description: In the file bin/pax/cache.c for the functions name_uid() and name_gid() the cacheing is not working. I already submitted the same fix to OpenBSD and it's been committed. I expect the same bug has existed since 4.4 since all of the BSD's seem to have it. Anyway, when a uid/gid is not found in the hashed table then a chunk of memory is allocated to "ptr" and then the info is looked up and stored in "ptr". This info in "ptr" is never added to the table. The memory now leaks away and no information has been cached. So the cache doesn't work. >How-To-Repeat: Read the code. Otherwise you can run a trace on function calls and see getpwuid() and getgrgid() get called repeatedly for the same id's when an archive is being extracted. >Fix: This is the diff as applied to OpenBSD for bin/pax/cache.c: @@ -204,7 +204,7 @@ ++pwopn; } if (ptr == NULL) - ptr = (UIDC *)malloc(sizeof(UIDC)); + ptr = uidtb[uid % UID_SZ] = malloc(sizeof(UIDC)); if ((pw = getpwuid(uid)) == NULL) { /* @@ -270,7 +270,7 @@ ++gropn; } if (ptr == NULL) - ptr = (GIDC *)malloc(sizeof(GIDC)); + ptr = gidtb[gid % GID_SZ] = malloc(sizeof(GIDC)); if ((gr = getgrgid(gid)) == NULL) { /* >Release-Note: >Audit-Trail: >Unformatted: