tar xf a.tar dir/dir fix added to svn

Denis Vlasenko vda.linux at googlemail.com
Sun Sep 3 14:03:54 UTC 2006


On Saturday 02 September 2006 22:26, Bernhard Fischer wrote:
> On Sat, Sep 02, 2006 at 09:15:44PM +0200, Denis Vlasenko wrote:
> 
> >I also added a testsuite entry.
> >
> >However, http://bugs.busybox.net/view.php?id=991
> >contains a bit different looking patch.
> >
> >I am not closind that one for now.
> 
> #991 does fix this in a more generic (albeit possibly slightly bigger)
> way.

Ok, applied slightly modified version of it:

+const llist_t *find_list_entry2(const llist_t *list, const char *filename)
+{
+       char buf[PATH_MAX];
+       int pattern_slash_cnt;
+       const char *c;
+       char *d;
+
+       while (list) {
+               c = list->data;
+               pattern_slash_cnt = 0;
+               while (*c)
+                       if (*c++ == '/') pattern_slash_cnt++;
+               c = filename;
+               d = buf;
+               /* paranoia is better that buffer overflows */
+               while (*c && d != buf + sizeof(buf)-1) {
+                       if (*c == '/' && --pattern_slash_cnt < 0)
+                               break;
+                       *d++ = *c++;
+               }
+               *d = '\0';
+               if (fnmatch(list->data, buf, 0) == 0) {
+                       return list;
+               }
+               list = list->link;
+       }
+       return NULL;
+}

> See
> http://www.busybox.net/lists/busybox/2006-April/020578.html
> and
> platform.h

You mean that FNM_LEADING_DIR is a GNUism?
Yes, this is bad, todo...

> Simply removing that hunk from platform.h would be improper, IMO.

I agree on this.
--
vda



More information about the busybox mailing list