mirror of
https://github.com/xroche/httrack.git
synced 2026-07-16 22:00:45 +03:00
Compare commits
1 Commits
fix-602-pr
...
docs-squas
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
052f86cdf3 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -43,6 +43,3 @@ Makefile
|
||||
|
||||
# Python bytecode (tests/local-server.py).
|
||||
__pycache__/
|
||||
|
||||
# Per-checkout Claude Code rules (symlink into a local sandbox).
|
||||
/CLAUDE.local.md
|
||||
|
||||
1
CLAUDE.local.md
Symbolic link
1
CLAUDE.local.md
Symbolic link
@@ -0,0 +1 @@
|
||||
/home/roche/git/httrack-works/CLAUDE.httrack.local.md
|
||||
20
src/htslib.c
20
src/htslib.c
@@ -65,7 +65,6 @@ Please visit our Website: http://www.httrack.com
|
||||
#endif /* _WIN32 */
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
@@ -3748,20 +3747,6 @@ static int proxy_default_port(const char *arg) {
|
||||
return hts_proxy_is_socks(arg) ? 1080 : 8080;
|
||||
}
|
||||
|
||||
// port "a" of -P argument "arg": digits fitting TCP's 1..65535, else the scheme
|
||||
// default. Not sscanf("%d"): past INT_MAX it wraps to a garbage port (#602)
|
||||
static int parse_proxy_port(const char *a, const char *arg) {
|
||||
char *end;
|
||||
long p;
|
||||
|
||||
if (!isdigit((unsigned char) *a)) // strtol would eat a sign or leading space
|
||||
return proxy_default_port(arg);
|
||||
p = strtol(a, &end, 10);
|
||||
if (*end != '\0' || p < 1 || p > 65535) // ERANGE lands out of range too
|
||||
return proxy_default_port(arg);
|
||||
return (int) p;
|
||||
}
|
||||
|
||||
void hts_parse_proxy(const char *arg, char *name, size_t name_size, int *port) {
|
||||
const char *authority = strstr(arg, "://");
|
||||
const char *a;
|
||||
@@ -3777,7 +3762,10 @@ void hts_parse_proxy(const char *arg, char *name, size_t name_size, int *port) {
|
||||
while (a > authority && a[-1] != ':' && a[-1] != '@' && a[-1] != ']')
|
||||
a--;
|
||||
if (a > authority && a[-1] == ':') {
|
||||
*port = parse_proxy_port(a, arg);
|
||||
int p = -1;
|
||||
|
||||
sscanf(a, "%d", &p);
|
||||
*port = (p > 0) ? p : proxy_default_port(arg);
|
||||
namelen = (size_t) (a - 1 - arg);
|
||||
} else {
|
||||
*port = proxy_default_port(arg);
|
||||
|
||||
@@ -71,23 +71,3 @@ p 'http://a]b:c@host' 'name=http://a]b:c@host port=8080 host=host kind=http'
|
||||
|
||||
# a lone ':' must not underflow the backward scan
|
||||
p ':' 'name= port=8080 host= kind=http'
|
||||
|
||||
# a port is *DIGIT in 1..65535, else the scheme default: sscanf("%d") used to
|
||||
# wrap past INT_MAX and hand back a garbage port (#602)
|
||||
p 'http://host:65535' 'name=http://host port=65535 host=host kind=http'
|
||||
p 'http://host:1' 'name=http://host port=1 host=host kind=http'
|
||||
p 'http://host:65536' 'name=http://host port=8080 host=host kind=http'
|
||||
p 'http://host:2147483648' 'name=http://host port=8080 host=host kind=http'
|
||||
p 'http://host:4294967296' 'name=http://host port=8080 host=host kind=http'
|
||||
p 'http://host:99999999999999' 'name=http://host port=8080 host=host kind=http'
|
||||
# discriminating: this one wrapped to a plausible 80, so range-checking the
|
||||
# sscanf result instead of rejecting the overflow still passes everything above
|
||||
p 'http://host:4294967376' 'name=http://host port=8080 host=host kind=http'
|
||||
p 'http://host:999999999999999999999999999999' 'name=http://host port=8080 host=host kind=http'
|
||||
p 'http://host:0' 'name=http://host port=8080 host=host kind=http'
|
||||
p 'http://host:-1' 'name=http://host port=8080 host=host kind=http'
|
||||
p 'http://host:80x' 'name=http://host port=8080 host=host kind=http'
|
||||
p 'http://host: 80' 'name=http://host port=8080 host=host kind=http'
|
||||
p 'http://host:' 'name=http://host port=8080 host=host kind=http'
|
||||
# the fallback is the scheme's own default, not a hardcoded 8080
|
||||
p 'socks5://host:99999999999999' 'name=socks5://host port=1080 host=host kind=socks'
|
||||
|
||||
Reference in New Issue
Block a user