Dear lftp-devel list,

I'm not sure if this is already known/fixed, so I'm sorry for bothering,
if you fixed it already.

With the latest 3.6.1 (I did not test CVS live, but I've checked
sources), I have encoutered this behaviour:

lftp :~> lftp http://foobar.com:60000/
---- Resolving host address...
---- 1 address found
---- Connecting to foobar.com (127.0.0.1) port 60000
---- Sending request...
---> HEAD / HTTP/1.1
---> Host: foobar.com:foobar.com
--->
<--- HTTP/1.1 400 Bad Request

As you can see, the port part of Host tag is malformed (hostname
duplicated instead of actual port). Older versions haven't this bug (not
necessarily the previous version), since they didn't use xstrings so
heavily.

I'm including a little patch for this issue. Call to xstring::join
contains two url::encode calls, since url::encode returns pointer to a
static xstring buffer, it calls xstring::join with the very same address
two times.

Thank you for a really sophisticated ftp/http/sftp client.

Regards,
RW

--- Http.cc_3.6.1       2008-01-02 06:06:30.000000000 +0100
+++ Http.cc     2008-01-02 06:04:44.000000000 +0100
@@ -236,10 +236,14 @@
 
 void Http::SendMethod(const char *method,const char *efile)
 {
+   char *tmp;
    const char *ehost=xstring::join(":",2,
       url::encode(hostname,URL_HOST_UNSAFE),
-      url::encode(portname,URL_PORT_UNSAFE)
+      (tmp=xstrdup(url::encode(portname,URL_PORT_UNSAFE)))
    );
+
+   xfree(tmp);
+
    if(!use_head && !strcmp(method,"HEAD"))
       method="GET";
    last_method=method;

Reply via email to