cURL / Mailing Lists / curl-users / Single Mail

curl-users

Multiple redirections bug (patch)

From: Ingo Wilken <iw_at_WWW.Ecce-Terram.DE>
Date: Thu, 10 May 2001 20:39:37 +0200 (MET DST)

I found a bug with multiple relocations:

curl -i -L -v http://www.e-gourmet.at

# * Connected to www.e-gourmet.at (193.83.204.16)
# > GET / HTTP/1.1
# User-Agent: curl/7.7.3 (i686-pc-linux-gnu) libcurl 7.7.3 (OpenSSL 0.9.6a)
# Host: www.e-gourmet.at
# Pragma: no-cache
# Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
#
# HTTP/1.1 302 Object moved
# Server: Microsoft-IIS/4.0
# Date: Thu, 10 May 2001 18:25:36 GMT
# Location: http://www.billa.at
# Content-Type: text/html
# Set-Cookie: ASPSESSIONIDGQGGQQBZ=OCOFIJJAGEAMMAODLOEEGOHD; path=/
# Cache-control: private
# Transfer-Encoding: chunked
#
# * Follow to new URL: http://www.billa.at
# * Connection (#0) left alive
# * Follows Location: to new URL: 'http://www.billa.at'
# * Disables POST
# * Connected to www.billa.at (193.83.204.30)
# > GET / HTTP/1.1
# User-Agent: curl/7.7.3 (i686-pc-linux-gnu) libcurl 7.7.3 (OpenSSL 0.9.6a)
# Host: www.billa.at
# Pragma: no-cache
# Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
#
# HTTP/1.1 302 Object moved
# Server: Microsoft-IIS/4.0
# Date: Thu, 10 May 2001 18:25:37 GMT
# Location: custom/default.asp
# Content-Type: text/html
# Set-Cookie: ASPSESSIONIDGGQGGHCG=HECLLMJAGKPHADAEPDJAAHGM; path=/
# Cache-control: private
# Transfer-Encoding: chunked
#
# * Follow to new URL: custom/default.asp
# * Connection (#1) left alive
# * Follows Location: to new URL: 'http://www.billa.at/custom/default.asp'
# * Disables POST
# * Re-using existing connection! (#1)
# * Connected to www.billa.at (193.83.204.30)
# > GET /custom/default.asp HTTP/1.1
# User-Agent: curl/7.7.3 (i686-pc-linux-gnu) libcurl 7.7.3 (OpenSSL 0.9.6a)
# Host: www.billa.at
# Pragma: no-cache
# Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
#
# HTTP/1.1 200 OK
# Server: Microsoft-IIS/4.0
# Date: Thu, 10 May 2001 18:25:37 GMT
# Content-Type: text/html
# Expires: Thu, 10 May 2001 18:25:37 GMT
# Set-Cookie: ASPSESSIONIDGGQGGHCG=IECLLMJACOKOBLKJCCMCAHHK; path=/
# Cache-control: private
# Transfer-Encoding: chunked
#
# * Follow to new URL: custom/default.asp
# * Connection (#1) left alive
# * Follows Location: to new URL: 'http://www.billa.at/custom/custom/default.asp'
# * Re-using existing connection! (#1)
# * Connected to www.billa.at (193.83.204.30)
# > GET /custom/custom/default.asp HTTP/1.1
# User-Agent: curl/7.7.3 (i686-pc-linux-gnu) libcurl 7.7.3 (OpenSSL 0.9.6a)
# Host: www.billa.at
# Pragma: no-cache
# Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
#
# * Follow to new URL: custom/default.asp
# * Connection (#1) left alive
# * Follows Location: to new URL: 'http://www.billa.at/custom/custom/custom/default.asp'
# * Re-using existing connection! (#1)
# * Connected to www.billa.at (193.83.204.30)
# > GET /custom/custom/custom/default.asp HTTP/1.1
# User-Agent: curl/7.7.3 (i686-pc-linux-gnu) libcurl 7.7.3 (OpenSSL 0.9.6a)
# Host: www.billa.at
# Pragma: no-cache
# Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
#
# * Follow to new URL: custom/default.asp
# * Connection (#1) left alive
# * Follows Location: to new URL: 'http://www.billa.at/custom/custom/custom/custom/default.asp'
# * Re-using existing connection! (#1)
# * Connected to www.billa.at (193.83.204.30)
# > GET /custom/custom/custom/custom/default.asp HTTP/1.1
# User-Agent: curl/7.7.3 (i686-pc-linux-gnu) libcurl 7.7.3 (OpenSSL 0.9.6a)
# Host: www.billa.at
# Pragma: no-cache
# Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
#
# HTTP/1.1 404 Object Not Found
# Server: Microsoft-IIS/4.0
# Date: Thu, 10 May 2001 18:25:37 GMT
# Connection: close
# Content-Type: text/html
# Content-Length: 461
#
# * Follow to new URL: custom/default.asp
# * Closing live connection (#1)
# * Follows Location: to new URL: 'http://www.billa.at/custom/custom/custom/custom/custom/default.asp'
# * Connected to www.billa.at (193.83.204.30)
# > GET /custom/custom/custom/custom/custom/default.asp HTTP/1.1
# User-Agent: curl/7.7.3 (i686-pc-linux-gnu) libcurl 7.7.3 (OpenSSL 0.9.6a)
# Host: www.billa.at
# Pragma: no-cache
# Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
#
# HTTP/1.1 404 Object Not Found
# Server: Microsoft-IIS/4.0
# Date: Thu, 10 May 2001 18:25:38 GMT
# Connection: close
# Content-Type: text/html
# Content-Length: 461
#
# <html><head><title>Error 404</title>
#
# <meta name="robots" content="noindex">
# <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"></head>
#
# <body>
#
# <h2>HTTP Error 404</h2>
#
# <p><strong>404 Not Found</strong></p>
#
# <p>The Web server cannot find the file or script you asked for. Please check the URL to ensure that the path is correct.</p>
#
# <p>Please contact the server's administrator if this problem persists.</p>
#
# * Closing live connection (#1)
# * Closing live connection (#0)

I fixed it by releasing conn->newurl in Curl_done(), but I'm not sure if
this is ok, it might break something else.

----cut here----
diff -cwr curl-7.7.3-orig/lib/url.c curl-7.7.3-1/lib/url.c
*** curl-7.7.3-orig/lib/url.c Fri May 4 09:47:11 2001
--- curl-7.7.3-1/lib/url.c Thu May 10 20:29:37 2001
***************
*** 2227,2232 ****
--- 2227,2237 ----
      conn->bits.rangestringalloc = FALSE;
    }
  
+ if(conn->newurl) {
+ free(conn->newurl);
+ conn->newurl = NULL;
+ }
+
    /* this calls the protocol-specific function pointer previously set */
    if(conn->curl_done)
      result = conn->curl_done(conn);
----cut here----

Regards,
Ingo

-- 
ECCE TERRAM Internet Services GmbH          Ingo Wilken
Edewechter Landstr. 42                      delta_at_ecce-terram.de
26131 Oldenburg                             ++49 (0)441/500-12-0
Received on 2001-05-10