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

[patch] dbootstrap/http-fetch



Dear Friends

I think, nf_http_fetchfile() in dbootstrap/http-fetch.c has a 
minor bug when requesting files over http.
http-fetch.c uses a absolute-URI regardless if it connects to 
a proxy or a host. This violates rfc1945:
"The absoluteURI form is only allowed when the request is 
being made to a proxy." (Section 5.1.2).

This trivial patch against bootfloppies-2.2.8 should fix the 
problem (warning, I didn't test nor compiled this "fix"):
---------------------------------------8<---------------------------------
--- http-fetch.c.orig   Wed Mar  1 18:42:51 2000
+++ http-fetch.c        Tue Mar 21 17:24:42 2000
@@ -39,6 +39,7 @@
 
 #if defined (_TESTING_)
   #define _DEBUG_
+B
 #endif
 
 #if defined (_TESTING_) && defined (_DEBUG_)
@@ -173,7 +174,7 @@
   int                 con_port;
   char                buf[65336];
   FILE               *fp;
-  int                 seen_reply_header, seen_http_ok;
+  int                 seen_reply_header, seen_http_ok, use_proxy;
   int                 offset;
   long                content_length;
   long                bytes_read;
@@ -189,10 +190,12 @@
    && proxy_port > 0) {
     con_host = proxy_host;
     con_port = proxy_port;
+    use_proxy = 1;
   }
   else {
     con_host = server_host;
     con_port = server_port;
+    use_proxy = 0;
   }
 
 #if defined (_TESTING_) && defined (_DEBUG_)
@@ -247,10 +250,14 @@
     perrorBox("nf_http_fetchfile :: nf_http_set_nonblock");
     return -1;
   }
-
-  snprintf(buf, sizeof buf - 1,
-           "GET http://%s:%d/%s/%s HTTP/1.0\n\n",
-           server_host, server_port, remote_path, remote_filename);
+  
+  if( use_proxy ) 
+       snprintf(buf, sizeof buf - 1,
+               "GET http://%s:%d/%s/%s HTTP/1.0\n\n",
+               server_host, server_port, remote_path, remote_filename);
+  else
+       snprintf(buf, sizeof buf - 1,
+                "GET /%s/%s HTTP/1.0\n\n", remote_path, remote_filename);
 
   if (nf_http_write(sock, buf) < 0) {
     close(sock);
---------------------------------------8<---------------------------------

best regards
 Michael

-- 
GPG Fingerprint = EA71 B296 4597 4D8B 343E  821E 9624 83E1 5662 C734
 /"\                                     o
 \ /     ASCII RIBBON CAMPAIGN          /|\
  X        AGAINST HTML MAIL             >>
 / \                                     o


Reply to: