hurdextras-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

httpfs ChangeLog http.c


From: Samuel Thibault
Subject: httpfs ChangeLog http.c
Date: Fri, 25 Jan 2013 00:50:59 +0000

CVSROOT:        /cvsroot/hurdextras
Module name:    httpfs
Changes by:     Samuel Thibault <sthibaul>      13/01/25 00:50:59

Modified files:
        .              : ChangeLog http.c 

Log message:
        2012-09-30  Cyril Roelandt  <address@hidden>
        2013-01-25  Samuel Thibault  <address@hidden>
        
                * http.c (fill_dirnode): Fix URL parsing, add 1 to conn_req 
size in
                cases which will need an additional trailing slash.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/httpfs/ChangeLog?cvsroot=hurdextras&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/httpfs/http.c?cvsroot=hurdextras&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/hurdextras/httpfs/ChangeLog,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- ChangeLog   25 Jan 2013 00:40:39 -0000      1.7
+++ ChangeLog   25 Jan 2013 00:50:58 -0000      1.8
@@ -4,6 +4,12 @@
        * Makefile.am: Link -lpthread instead of -lthreads.
 
 2012-09-30  Cyril Roelandt  <address@hidden>
+2013-01-25  Samuel Thibault  <address@hidden>
+
+       * http.c (fill_dirnode): Fix URL parsing, add 1 to conn_req size in
+       cases which will need an additional trailing slash.
+
+2012-09-30  Cyril Roelandt  <address@hidden>
 
        * netfs.c (netfs_attempt_utimes): Copy atime and mtime timespec
        structures into node->nn_stat.st_atim/st_mtim.

Index: http.c
===================================================================
RCS file: /cvsroot/hurdextras/httpfs/http.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- http.c      25 Jan 2013 00:42:23 -0000      1.2
+++ http.c      25 Jan 2013 00:50:58 -0000      1.3
@@ -219,24 +219,19 @@
                                 * its name is altered by changing / to .
                                 * www.gnu.org/gpl.html will be changed to
                                 * www.gnu.org.gpl.html */
+                               char *slash;
                                conn_req=(char 
*)malloc((strlen(go->f_name)+8)*sizeof(char));
+                               slash = strchr(go->f_name, '/');
+                               if (slash)
+                                       url = strndup(go->f_name, slash - 
go->f_name);
+                               else
                                url  = strdup(go->f_name);
-                               strcpy(url,strtok(url,"/"));
-                               temp = strdup(go->f_name);
-                               f_name = (char *) 
malloc(strlen(go->f_name)*sizeof(char));
-                               bzero(f_name,sizeof(f_name));
-                               while ( temp!=NULL && strchr(temp,'/') != NULL )
-                               {
-                                       /* find / replace it with . */
-                                       temp1 = strdup(temp);
-                                       strcat(f_name,strtok(temp1,"/"));
-                                       strcpy(temp,strchr(temp,'/'));
-                                       temp++;  
-                                       if ( strchr(temp,'/') != NULL )
-                                               strcat(f_name,".");
-                               }
-                               if ( strlen(temp) > 0 )
-                                       strcat(f_name,temp);
+                               f_name = strdup(go->f_name);
+                               int i;
+                               for (i = 0; f_name[i] != '\0'; i++)
+                                       if (f_name[i] == '/')
+                                               f_name[i] = '.';
+                               
                                sprintf(conn_req,"%s%s","http://",go->f_name);
                        }
                        else 
@@ -246,7 +241,10 @@
                                url=strdup(dir->url);
                                if ( go != list_of_entries )
                                {
-                                       conn_req=(char 
*)malloc((strlen(dir->conn_req)+strlen(go->f_name)+1)*sizeof(char));
+                                       size_t conn_req_size = 
strlen(dir->conn_req) + strlen(go->f_name) + 1;
+                                       if( go->f_type==HTTP_DIR || 
go->f_type==HTTP_DIR_NOT_FILLED )
+                                               conn_req_size++; /* We'll need 
to add a trailing slash later. */
+                                       conn_req=(char 
*)malloc(conn_req_size*sizeof(char));
                                        
sprintf(conn_req,"%s%s",dir->conn_req,go->f_name);
                                }
                                else
@@ -256,7 +254,10 @@
                                                /* the file corresponding to 
base url
                                                 * user has given a file 
explicitly in
                                                 * the url */
-                                               conn_req=(char 
*)malloc((strlen(dir->conn_req)+strlen(go->f_name)+1)*sizeof(char));
+                                               size_t conn_req_size = 
strlen(dir->conn_req) + strlen(go->f_name) + 1;
+                                               if( go->f_type==HTTP_DIR || 
go->f_type==HTTP_DIR_NOT_FILLED )
+                                                       conn_req_size++; /* 
We'll need to add a trailing slash later. */
+                                               conn_req=(char 
*)malloc(conn_req_size*sizeof(char));
                                                
sprintf(conn_req,"%s%s",dir->conn_req,go->f_name);
                                        }
                                        else 
@@ -264,8 +265,10 @@
                                                /* the file corresponding to 
base url
                                                 * user has not given a file 
explicitly 
                                                 * the url so its the 
index.html */
-                                               
-                                               conn_req=(char 
*)malloc((strlen(dir->conn_req)+1)*sizeof(char));
+                                               size_t conn_req_size = 
strlen(dir->conn_req) + 1;
+                                               if( go->f_type==HTTP_DIR || 
go->f_type==HTTP_DIR_NOT_FILLED )
+                                                       conn_req_size++; /* 
We'll need to add a trailing slash later. */
+                                               conn_req=(char 
*)malloc(conn_req_size*sizeof(char));
                                                
sprintf(conn_req,"%s",dir->conn_req);
                                        }
                                }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]