summaryrefslogtreecommitdiff
path: root/networking/wget.c
diff options
context:
space:
mode:
authorRandolph Chung <tausq@debian.org>2000-12-07 03:53:47 +0000
committerRandolph Chung <tausq@debian.org>2000-12-07 03:53:47 +0000
commit02553a2a188d3fe00d2c2efe48109eb3d4aae4b3 (patch)
treef67ea4db02cdb3416807006a41e9c92477f6ba41 /networking/wget.c
parent3d957c87b7525c3bfefddfc9aa2c24f04995275d (diff)
downloadbusybox-w32-02553a2a188d3fe00d2c2efe48109eb3d4aae4b3.tar.gz
busybox-w32-02553a2a188d3fe00d2c2efe48109eb3d4aae4b3.tar.bz2
busybox-w32-02553a2a188d3fe00d2c2efe48109eb3d4aae4b3.zip
Fixed URL parsing bug
Fixed -O - output-to-stdout bug
Diffstat (limited to 'networking/wget.c')
-rw-r--r--networking/wget.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/networking/wget.c b/networking/wget.c
index 78db6e32a..4a5934883 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -71,7 +71,11 @@ int wget_main(int argc, char **argv)
71 ++do_continue; 71 ++do_continue;
72 break; 72 break;
73 case 'O': 73 case 'O':
74 fname_out = (strcmp(optarg, "-") == 0 ? NULL : optarg); 74 /* can't set fname_out to NULL if outputting to stdout, because
75 * this gets interpreted as the auto-gen output filename
76 * case below - tausq@debian.org
77 */
78 fname_out = (strcmp(optarg, "-") == 0 ? (char *)1 : optarg);
75 break; 79 break;
76 default: 80 default:
77 usage(wget_usage); 81 usage(wget_usage);
@@ -110,12 +114,12 @@ int wget_main(int argc, char **argv)
110 /* 114 /*
111 * Open the output stream. 115 * Open the output stream.
112 */ 116 */
113 if (fname_out != NULL) { 117 if (fname_out != (char *)1) {
114 if ( (output=fopen(fname_out, (do_continue ? "a" : "w"))) 118 if ( (output=fopen(fname_out, (do_continue ? "a" : "w")))
115 == NULL) 119 == NULL)
116 fatalPerror("fopen(%s)", fname_out); 120 fatalPerror("fopen(%s)", fname_out);
117 } else { 121 } else {
118 output=stdout; 122 output = stdout;
119 } 123 }
120 124
121 /* 125 /*
@@ -202,6 +206,7 @@ int wget_main(int argc, char **argv)
202void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path) 206void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path)
203{ 207{
204 char *s, *h; 208 char *s, *h;
209 static char *defaultpath = "/";
205 210
206 *uri_port = 80; 211 *uri_port = 80;
207 212
@@ -209,9 +214,7 @@ void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path)
209 fatalError("not an http url: %s\n", url); 214 fatalError("not an http url: %s\n", url);
210 215
211 /* pull the host portion to the front of the buffer */ 216 /* pull the host portion to the front of the buffer */
212 for (s = url, h = url+7 ; *h != '/' ; ++h) { 217 for (s = url, h = url+7 ; *h != '/' && *h != 0; ++h) {
213 if (*h == '\0')
214 fatalError("cannot parse url: %s\n", url);
215 if (*h == ':') { 218 if (*h == ':') {
216 *uri_port = atoi(h+1); 219 *uri_port = atoi(h+1);
217 *h = '\0'; 220 *h = '\0';
@@ -219,6 +222,9 @@ void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path)
219 *s++ = *h; 222 *s++ = *h;
220 } 223 }
221 *s = '\0'; 224 *s = '\0';
225
226 if (*h == 0) h = defaultpath;
227
222 *uri_host = url; 228 *uri_host = url;
223 *uri_path = h; 229 *uri_path = h;
224} 230}
@@ -469,7 +475,7 @@ progressmeter(int flag)
469 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 475 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
470 * SUCH DAMAGE. 476 * SUCH DAMAGE.
471 * 477 *
472 * $Id: wget.c,v 1.7 2000/11/14 23:29:24 andersen Exp $ 478 * $Id: wget.c,v 1.8 2000/12/07 03:53:47 tausq Exp $
473 */ 479 */
474 480
475 481