bb tar (1.1.3) bug?

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Tue Jul 18 04:08:22 PDT 2006


bb tar extracting behaviour differs from gnu-tar.
Consider this tar-ball:

# busybox tar tvf ../bb.tar
drwxr-xr-x 339/500         0 2006-07-18 12:35:23 3
drwxr-xr-x 339/500         0 2006-07-18 12:35:23 2
drwxr-xr-x 339/500         0 2006-07-18 12:36:03 1
drwxr-xr-x 339/500         0 2006-07-18 12:36:38 1/10
drwxr-xr-x 339/500         0 2006-07-18 12:36:38 1/10/100
drwxr-xr-x 339/500         0 2006-07-18 12:36:38 1/10/101
drwxr-xr-x 339/500         0 2006-07-18 12:36:38 1/10/102
drwxr-xr-x 339/500         0 2006-07-18 12:36:03 1/11

I want to extract everything below directory 1/10:

# busybox tar xvf ../bb.tar 1/10
1/10

Yes, only directory 1/10 is extracted, but using gnu-tar:

# tar xvf ../bb.tar 1/10
1/10/
1/10/100/
1/10/101/
1/10/102/

I get what I expect.

This patch works for me:

---8<---
Index: find_list_entry.c
===================================================================
RCS file: /cvs/busybox/archival/libunarchive/find_list_entry.c,v
retrieving revision 1.1.1.2
retrieving revision 1.4
diff -u -b -B -p -r1.1.1.2 -r1.4
--- find_list_entry.c	29 Jun 2006 16:18:07 -0000	1.1.1.2
+++ find_list_entry.c	18 Jul 2006 09:17:13 -0000	1.4
@@ -21,7 +21,7 @@
 const llist_t *find_list_entry(const llist_t *list, const char *filename)
 {
 	while (list) {
-		if (fnmatch(list->data, filename, 0) == 0) {
+		if (fnmatch(list->data, filename, FNM_LEADING_DIR) == 0) {
 			return(list);
 		}
 		list = list->link;
---8<---

I vaguely recall this matter being discussed on the list, but my
memory may fail me. Didn't test 1.2.0 or svn trunk, but the code does
not seem to have changed much wrt this particular case. And, by the
way, fnmatch _is_ called with the FNM_LEADING_DIR flag in other places:

./tar.c:301:			if (fnmatch(excluded_files->data, file,
./tar.c-302-						FNM_PATHNAME | FNM_LEADING_DIR) == 0)
--
./tar.c:309:					fnmatch(excluded_files->data, p,
./tar.c-310-							FNM_PATHNAME | FNM_LEADING_DIR) == 0)


Cheers,
Cristian


More information about the busybox mailing list