8e24fc9
--- vsftpd-2.0.4/ls.c.orig	2005-05-23 23:55:00.000000000 +0200
8e24fc9
+++ vsftpd-2.0.4/ls.c	2006-07-11 01:02:21.000000000 +0200
8e24fc9
@@ -239,9 +239,31 @@
8e24fc9
   int ret = 0;
8e24fc9
   char last_token = 0;
8e24fc9
   int must_match_at_current_pos = 1;
8e24fc9
+  
8e24fc9
+  
8e24fc9
   str_copy(&filter_remain_str, p_filter_str);
8e24fc9
-  str_copy(&name_remain_str, p_filename_str);
8e24fc9
-
8e24fc9
+  
8e24fc9
+  if (!str_isempty (&filter_remain_str) && !str_isempty(p_filename_str)) {
8e24fc9
+    if (str_get_char_at(p_filter_str, 0) == '/') {
8e24fc9
+      if (str_get_char_at(p_filename_str, 0) != '/') {
8e24fc9
+        str_getcwd (&name_remain_str);
8e24fc9
+     
8e24fc9
+        if (str_getlen(&name_remain_str) > 1) /* cwd != root dir */
8e24fc9
+          str_append_char (&name_remain_str, '/');
8e24fc9
+          
8e24fc9
+        str_append_str (&name_remain_str, p_filename_str);
8e24fc9
+      }
8e24fc9
+      else
8e24fc9
+       str_copy (&name_remain_str, p_filename_str);
8e24fc9
+    } else {
8e24fc9
+      if (str_get_char_at(p_filter_str, 0) != '{')
8e24fc9
+        str_basename (&name_remain_str, p_filename_str);
8e24fc9
+      else
8e24fc9
+        str_copy (&name_remain_str, p_filename_str);
8e24fc9
+    }
8e24fc9
+  } else
8e24fc9
+    str_copy(&name_remain_str, p_filename_str);
8e24fc9
+  
8e24fc9
   while (!str_isempty(&filter_remain_str))
8e24fc9
   {
8e24fc9
     static struct mystr s_match_needed_str;
8e24fc9
--- vsftpd-2.0.4/str.h.orig	2004-06-04 18:35:00.000000000 +0200
8e24fc9
+++ vsftpd-2.0.4/str.h	2006-07-11 00:59:59.000000000 +0200
8e24fc9
@@ -96,6 +96,8 @@
8e24fc9
 int str_contains_space(const struct mystr* p_str);
8e24fc9
 int str_contains_unprintable(const struct mystr* p_str);
8e24fc9
 void str_replace_unprintable(struct mystr* p_str, char new_char);
8e24fc9
+void str_basename (struct mystr* d_str, const struct mystr* path);
8e24fc9
+
8e24fc9
 int str_atoi(const struct mystr* p_str);
8e24fc9
 filesize_t str_a_to_filesize_t(const struct mystr* p_str);
8e24fc9
 unsigned int str_octal_to_uint(const struct mystr* p_str);
8e24fc9
--- vsftpd-2.0.4/str.c.orig	2004-07-12 19:58:39.000000000 +0200
8e24fc9
+++ vsftpd-2.0.4/str.c	2006-07-11 00:59:59.000000000 +0200
8e24fc9
@@ -662,3 +662,14 @@
8e24fc9
   }
8e24fc9
 }
8e24fc9
 
8e24fc9
+void
8e24fc9
+str_basename (struct mystr* d_str, const struct mystr* path)
8e24fc9
+{
223ba13
+  static struct mystr tmp;
8e24fc9
+
8e24fc9
+  str_copy (&tmp, path);
8e24fc9
+  str_split_char_reverse(&tmp, d_str, '/');
8e24fc9
+
8e24fc9
+  if (str_isempty(d_str))
8e24fc9
+   str_copy (d_str, path);
8e24fc9
+}