diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-12-18 05:11:56 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-12-18 05:11:56 +0100 |
commit | 93b4a605263612cf32ad9de746a4fafaf4515115 (patch) | |
tree | 90b3001eea03128a5e25aeb9accb63cf38356dbc | |
parent | f282c6b65775d3dff03de6fd3585722a1638f734 (diff) | |
download | busybox-w32-93b4a605263612cf32ad9de746a4fafaf4515115.tar.gz busybox-w32-93b4a605263612cf32ad9de746a4fafaf4515115.tar.bz2 busybox-w32-93b4a605263612cf32ad9de746a4fafaf4515115.zip |
wget: fix use-after-free on redirect
function old new delta
wget_main 2153 2168 +15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/wget.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/networking/wget.c b/networking/wget.c index 94a2f7c3d..1991a1072 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -557,6 +557,7 @@ static void download_one_url(const char *url) | |||
557 | FILE *dfp; /* socket to ftp server (data) */ | 557 | FILE *dfp; /* socket to ftp server (data) */ |
558 | char *proxy = NULL; | 558 | char *proxy = NULL; |
559 | char *fname_out_alloc; | 559 | char *fname_out_alloc; |
560 | char *redirected_path = NULL; | ||
560 | struct host_info server; | 561 | struct host_info server; |
561 | struct host_info target; | 562 | struct host_info target; |
562 | 563 | ||
@@ -793,8 +794,8 @@ However, in real world it was observed that some web servers | |||
793 | bb_error_msg_and_die("too many redirections"); | 794 | bb_error_msg_and_die("too many redirections"); |
794 | fclose(sfp); | 795 | fclose(sfp); |
795 | if (str[0] == '/') { | 796 | if (str[0] == '/') { |
796 | free(target.allocated); | 797 | free(redirected_path); |
797 | target.path = target.allocated = xstrdup(str+1); | 798 | target.path = redirected_path = xstrdup(str+1); |
798 | /* lsa stays the same: it's on the same server */ | 799 | /* lsa stays the same: it's on the same server */ |
799 | } else { | 800 | } else { |
800 | parse_url(str, &target); | 801 | parse_url(str, &target); |
@@ -849,6 +850,7 @@ However, in real world it was observed that some web servers | |||
849 | free(server.allocated); | 850 | free(server.allocated); |
850 | free(target.allocated); | 851 | free(target.allocated); |
851 | free(fname_out_alloc); | 852 | free(fname_out_alloc); |
853 | free(redirected_path); | ||
852 | } | 854 | } |
853 | 855 | ||
854 | int wget_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 856 | int wget_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |