Bug 1057 - busybox wget segfaults with http_proxy environment set
Summary: busybox wget segfaults with http_proxy environment set
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: 1.16.x
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-08 11:09 UTC by Natanael Copa
Modified: 2010-02-11 03:24 UTC (History)
1 user (show)

See Also:
Host: i386
Target: i386
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Natanael Copa 2010-02-08 11:09:31 UTC
To reproduce:

(start a http proxy some place)
$ export http_proxy=http://proxy:8080
$ wget http://google.com
Connecting to proxy:8080 (10.65.64.4:8080)
Segmentation fault

Originally reported here:
http://redmine.alpinelinux.org/issues/show/264
Comment 1 Lionel Landwerlin 2010-02-08 11:17:30 UTC
(In reply to comment #0)
> To reproduce:
> 
> (start a http proxy some place)
> $ export http_proxy=http://proxy:8080
> $ wget http://google.com
> Connecting to proxy:8080 (10.65.64.4:8080)
> Segmentation fault
> 
> Originally reported here:
> http://redmine.alpinelinux.org/issues/show/264
> 

Haven't seen any problem here ...
I just ran a test with target i686 host amd64 using chroot.
I'm using wget from busybox.

What's yours ?
Comment 2 Natanael Copa 2010-02-08 11:26:32 UTC
Seems like running as './busybox wget' does not trigger the bug, while 'ln -s ./busybox wget &&  ./wget' does.

Backtrace:

Program received signal SIGSEGV, Segmentation fault.
0xb76057da in strlen () from /lib/libc.so.0
(gdb) bt
#0  0xb76057da in strlen () from /lib/libc.so.0
#1  0xb76898db in base64enc_512 (buf=0xbfffed54 "", str=<value optimized out>)
    at networking/wget.c:150
#2  0xb768a2f1 in wget_main (argc=2, argv=0xbffff0c4) at networking/wget.c:685
#3  0xb76673a0 in run_applet_no_and_exit (applet_no=266, argv=0xbffff0c4)
    at libbb/appletlib.c:746
#4  0xb76673dd in run_applet_and_exit (name=0xbffff242 "wget", argv=0xbffff0c4)
    at libbb/appletlib.c:753
#5  0xb76676de in main (argc=2, argv=0xbffff0c4) at libbb/appletlib.c:808
(gdb) 


Comment 3 Natanael Copa 2010-02-08 11:27:50 UTC
and i use uclibc-0.9.30.2 (alpinelinux)
Comment 4 Leonid 2010-02-09 19:21:08 UTC
I apologize that it is by-effect of commit be168b119750beacc0d0212607c6fa3ee87f238c

try patch below
--- a/networking/wget.c	2010-02-09 22:17:50.000000000 +0300
+++ b/networking/wget.c	2010-02-09 22:18:32.000000000 +0300
@@ -590,6 +590,7 @@ int wget_main(int argc UNUSED_PARAM, cha
 	if (use_proxy) {
 		proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy");
 		if (proxy && proxy[0]) {
+			server.user = NULL;
 			parse_url(proxy, &server);
 		} else {
 			use_proxy = 0;
Comment 5 Natanael Copa 2010-02-10 07:52:23 UTC
> try patch below
> --- a/networking/wget.c 2010-02-09 22:17:50.000000000 +0300
> +++ b/networking/wget.c 2010-02-09 22:18:32.000000000 +0300
> @@ -590,6 +590,7 @@ int wget_main(int argc UNUSED_PARAM, cha
>         if (use_proxy) {
>                 proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy");
>                 if (proxy && proxy[0]) {
> +                       server.user = NULL;
>                         parse_url(proxy, &server);
>                 } else {
>                         use_proxy = 0;
> 

works.
Please commit this to git master and 1_16_stable branch
thanks!
Comment 6 Denys Vlasenko 2010-02-11 03:24:54 UTC
Applied to git, thanks!