bin/64321: pax cacheing bug

Rodney Ruddock rodney at interopsystems.com
Mon Mar 15 21:00:36 PST 2004


>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:


More information about the freebsd-bugs mailing list