Bug 24745

Summary: /usr/bin/ftp program segfaults with following commandline
Product: Base System Reporter: jweaver <jweaver>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description jweaver 2001-01-31 00:00:01 UTC
Following http url commandline makes /usr/bin/ftp Segfault

Fix: 

Have no time to debug the code, sorry. =(
How-To-Repeat: bash-2.04$ ftp http://www.wfamaps.com/download.php?file=/pub/wfamaps/maps/map-2forts-wfa.zip
Requesting http://www.wfamaps.com/download.php?file=/pub/wfamaps/maps/map-2forts-wfa.zip
ftp: Error retrieving file: 404 Not Found

ftp in free(): warning: junk pointer, too high to make sense.
Segmentation fault (core dumped)
Comment 1 Alex Kapranoff 2001-01-31 06:46:11 UTC
On Tue, Jan 30, 2001 at 06:51:53PM -0500, jweaver@accountsupport.com wrote:

> >Description:
> Following http url commandline makes /usr/bin/ftp Segfault
> 
> >How-To-Repeat:
> bash-2.04$ ftp http://www.wfamaps.com/download.php?file=/pub/wfamaps/maps/map-2forts-wfa.zip
> Requesting http://www.wfamaps.com/download.php?file=/pub/wfamaps/maps/map-2forts-wfa.zip
> ftp: Error retrieving file: 404 Not Found
> 
> ftp in free(): warning: junk pointer, too high to make sense.
> Segmentation fault (core dumped)

  I confirm the bug under 4.2-STABLE. By the way, it works fine under
-CURRENT, so you can try to backport some -CURRENT diffs.

-- 
Alex Kapranoff,                              Voice: +7(0832)791845
We've lived 4 weeks in the brand new millenium...
Comment 2 Peter Pentchev 2001-01-31 07:25:35 UTC
On Tue, Jan 30, 2001 at 11:00:08PM -0800, Alex Kapranoff wrote:
> The following reply was made to PR bin/24745; it has been noted by GNATS.
> 
> From: Alex Kapranoff <kapr@acm.org>
> To: jweaver@accountsupport.com
> Cc: FreeBSD-gnats-submit@FreeBSD.ORG
> Subject: Re: bin/24745: ftp segfault condition
> Date: Wed, 31 Jan 2001 09:46:11 +0300
> 
>  On Tue, Jan 30, 2001 at 06:51:53PM -0500, jweaver@accountsupport.com wrote:
>  
>  > >Description:
>  > Following http url commandline makes /usr/bin/ftp Segfault
>  > 
>  > >How-To-Repeat:
>  > bash-2.04$ ftp http://www.wfamaps.com/download.php?file=/pub/wfamaps/maps/map-2forts-wfa.zip
>  > Requesting http://www.wfamaps.com/download.php?file=/pub/wfamaps/maps/map-2forts-wfa.zip
>  > ftp: Error retrieving file: 404 Not Found
>  > 
>  > ftp in free(): warning: junk pointer, too high to make sense.
>  > Segmentation fault (core dumped)
>  
>    I confirm the bug under 4.2-STABLE. By the way, it works fine under
>  -CURRENT, so you can try to backport some -CURRENT diffs.

Actually, this is pretty much the only difference between usr.bin/ftp/
in -stable and -current.  Try the attached patch, it does the trick
for me.

G'luck,
Peter

-- 
because I didn't think of a good beginning of it.

Index: src/usr.bin/ftp/fetch.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/ftp/fetch.c,v
retrieving revision 1.12.2.2
diff -u -r1.12.2.2 fetch.c
--- src/usr.bin/ftp/fetch.c	2000/06/24 15:35:46	1.12.2.2
+++ src/usr.bin/ftp/fetch.c	2001/01/31 07:24:16
@@ -270,6 +270,7 @@
 	break;
       }
 	freeaddrinfo(res0);
+	res0 = NULL;
 
 	/*
 	 * Construct and send the request.  We're expecting a return
Comment 3 ru freebsd_committer freebsd_triage 2001-01-31 08:25:06 UTC
State Changed
From-To: open->closed

Duplicate of PR bin/21476 (the latter was fixed).
Comment 4 des 2001-01-31 12:09:34 UTC
jweaver@accountsupport.com writes:
> Following http url commandline makes /usr/bin/ftp Segfault

Don't use ftp(1) for retrieving HTTP documents. It only pretends to
work. Use fetch(1), which makes a pretty good attempt at really
working.

DES
-- 
Dag-Erling Smorgrav - des@ofug.org