naming
authorChristian Grothoff <christian@grothoff.org>
Fri, 9 Jul 2010 10:23:40 +0000 (10:23 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 9 Jul 2010 10:23:40 +0000 (10:23 +0000)
TODO
src/fs/fs_download.c
src/fs/fs_file_information.c

diff --git a/TODO b/TODO
index 843b24bca6821f23ef54e1950a3e9ad7f35ce2f8..b61f4d16d1ad1f9267889c64fea6276f0bfa5270 100644 (file)
--- a/TODO
+++ b/TODO
@@ -17,9 +17,6 @@
   - implement testcases
   - implement performance tests
 * FS: [CG]
-  - publishing a directory sets the embedded filename to "empty" 
-    (likely an issue with cutting off everything before '/' in the filename,
-     which in the case of a directory would leave nothing)
   - trust: do not charge when "idle" / load considerations (migration, routing)
   - bound our priorities based on priorities used by other peers
   - datastore reservation (publishing)
index 1ee4355adc5516975e6248fd1767fa8c29ce736f..53bad312697178afa9ee1ef449b5f07156a12106 100644 (file)
@@ -702,6 +702,7 @@ trigger_recursive_download (void *cls,
   char *us;
   char *ext;
   char *dn;
+  char *pos;
   char *full_name;
 
   if (NULL == uri)
@@ -722,7 +723,7 @@ trigger_recursive_download (void *cls,
   fn = NULL;
   if (NULL == filename)
     {
-      fn = GNUNET_FS_meta_data_suggest_filename (meta);      
+      fn = GNUNET_FS_meta_data_suggest_filename (meta);
       if (fn == NULL)
        {
          us = GNUNET_FS_uri_to_string (uri);
@@ -741,6 +742,20 @@ trigger_recursive_download (void *cls,
          GNUNET_free (ext);
          GNUNET_free (us);
        }
+      /* change '\' to '/' (this should have happened
+       during insertion, but malicious peers may
+       not have done this) */
+      while (NULL != (pos = strstr (fn, "\\")))
+       *pos = '/';
+      /* remove '../' everywhere (again, well-behaved
+        peers don't do this, but don't trust that
+        we did not get something nasty) */
+      while (NULL != (pos = strstr (fn, "../")))
+       {
+         pos[0] = '_';
+         pos[1] = '_';
+         pos[2] = '_';
+       }
       filename = fn;
     }
   if (dc->filename == NULL)
index 1973e2bc163aa75dcc341ad87ed90c7df8136872..e0403b2ed39dc42679e87bab88deb44b433f1680 100644 (file)
@@ -612,8 +612,9 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
       dc.entries = dc.entries->next;
     }
   fn = filename;
-  while (NULL != (ss = strstr (fn,
-                              DIR_SEPARATOR_STR)))
+  while ( (NULL != (ss = strstr (fn,
+                                DIR_SEPARATOR_STR))) &&
+         (strlen (ss) > 1) )
     fn = ss + 1;
   GNUNET_CONTAINER_meta_data_insert (ret->meta,
                                     "<gnunet>",