Why is svn 14061 a good idea?

Rob Landley rob at landley.net
Tue Sep 5 03:46:54 UTC 2006


Ok, so this checkin replaces this:
> -               if (fnmatch(list->data, filename, FNM_LEADING_DIR) == 0) {
> -                       return (list);

With this:

+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;
+}

From a size perspective, how does that make sense?  I'm aware the previous 
wasn't portable, but this is much bigger and that's kind of important to us.  
How much do we actually care here?  (Question #1: does uClibc support it?)

Rob

P.S.  Please don't add bb_ prefixes to things unless there's an actual name 
collision (ala implementing our own version of an existing glibc function).
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list