diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-24 13:35:32 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-24 13:35:32 +0200 |
| commit | df45eb49acaeb64574e14f78c6bb5b95f1157058 (patch) | |
| tree | 7e6dc15d1eea8b9b6461489de3609ed0db1555af | |
| parent | f4eaccbfaee58d00f53fe106d018f4e9687b2e27 (diff) | |
| download | busybox-w32-df45eb49acaeb64574e14f78c6bb5b95f1157058.tar.gz busybox-w32-df45eb49acaeb64574e14f78c6bb5b95f1157058.tar.bz2 busybox-w32-df45eb49acaeb64574e14f78c6bb5b95f1157058.zip | |
wget: handle URLs with @ or hash differently
If server replied with 302 and
Location: ?foo
we used to underflow the allocated space while trying to form the "@foo"
filename. Switch to forming "foo" filename.
function old new delta
packed_usage 32795 32799 +4
parse_url 387 352 -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-35) Total: -31 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | networking/wget.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/networking/wget.c b/networking/wget.c index b6c76e9dc..30c339244 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
| @@ -539,7 +539,7 @@ static void parse_url(const char *src_url, struct host_info *h) | |||
| 539 | // and saves 'index.html?var=a%2Fb' (we save 'b') | 539 | // and saves 'index.html?var=a%2Fb' (we save 'b') |
| 540 | // wget 'http://busybox.net?login=john@doe': | 540 | // wget 'http://busybox.net?login=john@doe': |
| 541 | // request: 'GET /?login=john@doe HTTP/1.0' | 541 | // request: 'GET /?login=john@doe HTTP/1.0' |
| 542 | // saves: 'index.html?login=john@doe' (we save '?login=john@doe') | 542 | // saves: 'index.html?login=john@doe' (we save 'login=john@doe') |
| 543 | // wget 'http://busybox.net#test/test': | 543 | // wget 'http://busybox.net#test/test': |
| 544 | // request: 'GET / HTTP/1.0' | 544 | // request: 'GET / HTTP/1.0' |
| 545 | // saves: 'index.html' (we save 'test') | 545 | // saves: 'index.html' (we save 'test') |
| @@ -553,13 +553,13 @@ static void parse_url(const char *src_url, struct host_info *h) | |||
| 553 | } else if (*sp == '/') { | 553 | } else if (*sp == '/') { |
| 554 | *sp = '\0'; | 554 | *sp = '\0'; |
| 555 | h->path = sp + 1; | 555 | h->path = sp + 1; |
| 556 | } else { // '#' or '?' | 556 | } else { |
| 557 | // sp points to '#' or '?' | ||
| 558 | // Note: | ||
| 557 | // http://busybox.net?login=john@doe is a valid URL | 559 | // http://busybox.net?login=john@doe is a valid URL |
| 558 | // memmove converts to: | 560 | // (without '/' between ".net" and "?"), |
| 559 | // http:/busybox.nett?login=john@doe... | 561 | // can't store NUL at sp[-1] - this destroys hostname. |
| 560 | memmove(h->host - 1, h->host, sp - h->host); | 562 | *sp++ = '\0'; |
| 561 | h->host--; | ||
| 562 | sp[-1] = '\0'; | ||
| 563 | h->path = sp; | 563 | h->path = sp; |
| 564 | } | 564 | } |
| 565 | 565 | ||
