diff options
author | Matt Kraai <kraai@debian.org> | 2001-01-03 16:15:15 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2001-01-03 16:15:15 +0000 |
commit | a9711a59695d0c0591e8786a2ea811940ef8735a (patch) | |
tree | d18c561b9ab63ff7c458cbeb10a9bcaeffc45567 /networking/wget.c | |
parent | 59c09d06e34df81f55e463fc61e69d5081eb5161 (diff) | |
download | busybox-w32-a9711a59695d0c0591e8786a2ea811940ef8735a.tar.gz busybox-w32-a9711a59695d0c0591e8786a2ea811940ef8735a.tar.bz2 busybox-w32-a9711a59695d0c0591e8786a2ea811940ef8735a.zip |
Prevent / doubling and shrink parse_url.
Diffstat (limited to 'networking/wget.c')
-rw-r--r-- | networking/wget.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/networking/wget.c b/networking/wget.c index dbc283698..77577d9b4 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -241,31 +241,28 @@ int wget_main(int argc, char **argv) | |||
241 | 241 | ||
242 | void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path) | 242 | void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path) |
243 | { | 243 | { |
244 | char *s, *h; | 244 | char *cp, *sp; |
245 | static char *defaultpath = "/"; | ||
246 | 245 | ||
247 | *uri_port = 80; | 246 | *uri_port = 80; |
248 | 247 | ||
249 | if (strncmp(url, "http://", 7) != 0) | 248 | if (strncmp(url, "http://", 7) != 0) |
250 | error_msg_and_die("not an http url: %s\n", url); | 249 | error_msg_and_die("not an http url: %s\n", url); |
251 | 250 | ||
252 | /* pull the host portion to the front of the buffer */ | 251 | *uri_host = url + 7; |
253 | for (s = url, h = url+7 ; *h != '/' && *h != 0; ++h) { | ||
254 | if (*h == ':') { | ||
255 | *uri_port = atoi(h+1); | ||
256 | *h = '\0'; | ||
257 | } | ||
258 | *s++ = *h; | ||
259 | } | ||
260 | *s = '\0'; | ||
261 | 252 | ||
262 | if (*h == 0) h = defaultpath; | 253 | cp = strchr(*uri_host, ':'); |
254 | sp = strchr(*uri_host, '/'); | ||
263 | 255 | ||
264 | *uri_host = url; | 256 | if (cp != NULL && (sp == NULL || cp < sp)) { |
265 | *uri_path = h; | 257 | *cp++ = '\0'; |
258 | *uri_port = atoi(cp); | ||
259 | } | ||
266 | 260 | ||
267 | if (!strcmp( *uri_host, *uri_path)) | 261 | if (sp != NULL) { |
268 | *uri_path = defaultpath; | 262 | *sp++ = '\0'; |
263 | *uri_path = sp; | ||
264 | } else | ||
265 | *uri_path = ""; | ||
269 | } | 266 | } |
270 | 267 | ||
271 | 268 | ||
@@ -514,7 +511,7 @@ progressmeter(int flag) | |||
514 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 511 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
515 | * SUCH DAMAGE. | 512 | * SUCH DAMAGE. |
516 | * | 513 | * |
517 | * $Id: wget.c,v 1.14 2000/12/18 03:08:29 kraai Exp $ | 514 | * $Id: wget.c,v 1.15 2001/01/03 16:15:15 kraai Exp $ |
518 | */ | 515 | */ |
519 | 516 | ||
520 | 517 | ||