Blame SOURCES/vsftpd-2.1.0-filter.patch

bd78b8
diff -up vsftpd-2.1.0/ls.c.filter vsftpd-2.1.0/ls.c
bd78b8
--- vsftpd-2.1.0/ls.c.filter	2008-02-02 02:30:41.000000000 +0100
bd78b8
+++ vsftpd-2.1.0/ls.c	2009-01-08 19:31:15.000000000 +0100
bd78b8
@@ -239,9 +239,31 @@ vsf_filename_passes_filter(const struct 
bd78b8
   int ret = 0;
bd78b8
   char last_token = 0;
bd78b8
   int must_match_at_current_pos = 1;
bd78b8
+  
bd78b8
+  
bd78b8
   str_copy(&filter_remain_str, p_filter_str);
bd78b8
-  str_copy(&name_remain_str, p_filename_str);
bd78b8
-
bd78b8
+  
bd78b8
+  if (!str_isempty (&filter_remain_str) && !str_isempty(p_filename_str)) {
bd78b8
+    if (str_get_char_at(p_filter_str, 0) == '/') {
bd78b8
+      if (str_get_char_at(p_filename_str, 0) != '/') {
bd78b8
+        str_getcwd (&name_remain_str);
bd78b8
+     
bd78b8
+        if (str_getlen(&name_remain_str) > 1) /* cwd != root dir */
bd78b8
+          str_append_char (&name_remain_str, '/');
bd78b8
+          
bd78b8
+        str_append_str (&name_remain_str, p_filename_str);
bd78b8
+      }
bd78b8
+      else
bd78b8
+       str_copy (&name_remain_str, p_filename_str);
bd78b8
+    } else {
bd78b8
+      if (str_get_char_at(p_filter_str, 0) != '{')
bd78b8
+        str_basename (&name_remain_str, p_filename_str);
bd78b8
+      else
bd78b8
+        str_copy (&name_remain_str, p_filename_str);
bd78b8
+    }
bd78b8
+  } else
bd78b8
+    str_copy(&name_remain_str, p_filename_str);
bd78b8
+  
bd78b8
   while (!str_isempty(&filter_remain_str) && *iters < VSFTP_MATCHITERS_MAX)
bd78b8
   {
bd78b8
     static struct mystr s_match_needed_str;
bd78b8
diff -up vsftpd-2.1.0/str.c.filter vsftpd-2.1.0/str.c
bd78b8
--- vsftpd-2.1.0/str.c.filter	2008-12-17 06:54:16.000000000 +0100
bd78b8
+++ vsftpd-2.1.0/str.c	2009-01-08 19:31:15.000000000 +0100
bd78b8
@@ -680,3 +680,14 @@ str_replace_unprintable(struct mystr* p_
bd78b8
   }
bd78b8
 }
bd78b8
 
bd78b8
+void
bd78b8
+str_basename (struct mystr* d_str, const struct mystr* path)
bd78b8
+{
bd78b8
+  static struct mystr tmp;
bd78b8
+
bd78b8
+  str_copy (&tmp, path);
bd78b8
+  str_split_char_reverse(&tmp, d_str, '/');
bd78b8
+
bd78b8
+  if (str_isempty(d_str))
bd78b8
+   str_copy (d_str, path);
bd78b8
+}
bd78b8
diff -up vsftpd-2.1.0/str.h.filter vsftpd-2.1.0/str.h
bd78b8
--- vsftpd-2.1.0/str.h.filter	2008-12-17 06:53:23.000000000 +0100
bd78b8
+++ vsftpd-2.1.0/str.h	2009-01-08 19:32:14.000000000 +0100
bd78b8
@@ -100,6 +100,7 @@ void str_replace_unprintable(struct myst
bd78b8
 int str_atoi(const struct mystr* p_str);
bd78b8
 filesize_t str_a_to_filesize_t(const struct mystr* p_str);
bd78b8
 unsigned int str_octal_to_uint(const struct mystr* p_str);
bd78b8
+void str_basename (struct mystr* d_str, const struct mystr* path);
bd78b8
 
bd78b8
 /* PURPOSE: Extract a line of text (delimited by \n or EOF) from a string
bd78b8
  * buffer, starting at character position 'p_pos'. The extracted line will