From conallob@maths.tcd.ie  Sun Aug 21 13:40:41 2005
Return-Path: <conallob@maths.tcd.ie>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3156E16A41F;
	Sun, 21 Aug 2005 13:40:41 +0000 (GMT)
	(envelope-from conallob@maths.tcd.ie)
Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11])
	by mx1.FreeBSD.org (Postfix) with SMTP id 358CB43D45;
	Sun, 21 Aug 2005 13:40:39 +0000 (GMT)
	(envelope-from conallob@maths.tcd.ie)
Received: from walton.maths.tcd.ie  ([134.226.81.10] helo=walton.maths.tcd.ie)
          by salmon.maths.tcd.ie with SMTP id <aa13456@salmon>;
          21 Aug 2005 14:40:38 +0100 (BST)
Message-Id: <200508211440.aa07330@walton.maths.tcd.ie>
Date: Sun, 21 Aug 2005 14:40:38 +0100 (BST)
From: Conall O'Brien <conallob=freebsd@maths.tcd.ie>
Sender: conallob@maths.tcd.ie
Reply-To: Conall O'Brien <conallob=freebsd@maths.tcd.ie>
To: FreeBSD-gnats-submit@freebsd.org
Cc: David Malone <dwmalone@freebsd.org>, Ian Dowse <iedowse@freebsd.org>
Subject: Env Parser problem in libfetch
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         85185
>Category:       kern
>Synopsis:       [libfetch] [patch] Env Parser problem in libfetch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 21 13:50:00 GMT 2005
>Closed-Date:    Wed Dec 14 09:11:30 GMT 2005
>Last-Modified:  Wed Dec 14 09:11:30 GMT 2005
>Originator:     Conall O'Brien
>Release:        FreeBSD 4.11-STABLE i386
>Organization:
>Environment:
System: 
FreeBSD walton.maths.tcd.ie 4.11-STABLE FreeBSD 4.11-STABLE #25: Mon May 9 11:36:51 BST 2005 conallob@gosset.maths.tcd.ie:/mnt/obj/usr/src/sys/WALTON i386

FreeBSD sweetums.infocad.ie 5.4-STABLE FreeBSD 5.4-STABLE #4: Fri Aug  5 15:29:22 IST 2005     conall@sweetums.infocad.ie:/usr/src/obj/usr/src/sys/SWEETUMS  alpha

>Description:
fetch misunderstands envirometal variables http_proxy and HTTP_PROXY, 
if set to ""

As a result, fetch assumes the proxy host is "" and the proxy port is 
3124 and fails every time


An example:

fetch -vv http://www.google.com
scheme:   [http]
user:     []
password: []
host:     [www.google.com]
port:     [0]
document: [/]
scheme:   []
user:     []
password: []
host:     []
port:     [0]
document: [/]
---> :3128
looking up 
fetch: http://www.google.com: Host not found

>How-To-Repeat:
Behaviour has been reproduced on RELENG_4 and RELENG_5.

Set HTTP_PROXY or http_proxy to working proxy config, or unset 
variables accordingly and fetch works as expected.

(setenv | export) HTTP_PROXY or http_proxy to "" and fetch fails.
>Fix:
Use the same parser checks from src/lib/libfetch/ftp.c in 
src/lib/libfetch/http.c


--- http.c.orig Sun Aug 21 14:19:26 2005
+++ http.c      Sun Aug 21 14:22:26 2005
@@ -717,7 +717,7 @@
        if (flags != NULL && strchr(flags, 'd') != NULL)
                return (NULL);
        if (((p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) &&
-           (purl = fetchParseURL(p))) {
+           *p && (purl = fetchParseURL(p)) =! NULL) {
                if (!*purl->scheme)
                  strcpy(purl->scheme, SCHEME_HTTP);
                if (!purl->port)
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Wed Aug 24 11:57:52 GMT 2005 
Responsible-Changed-Why:  
Assign to author. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85185 
State-Changed-From-To: open->patched 
State-Changed-By: des 
State-Changed-When: Wed Aug 24 12:34:51 GMT 2005 
State-Changed-Why:  
Fixed in -CURRENT, awaiting MFC. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85185 
State-Changed-From-To: patched->closed 
State-Changed-By: des 
State-Changed-When: Wed Dec 14 09:11:28 UTC 2005 
State-Changed-Why:  
MFCed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85185 
>Unformatted:
