mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 19:30:29 +00:00
Fix connecting to localhost when only IP address is specified in Fetch()
This commit is contained in:
parent
14fd395f03
commit
9a7cb399e5
1 changed files with 4 additions and 5 deletions
|
@ -3819,12 +3819,11 @@ static int LuaFetch(lua_State *L) {
|
|||
} else {
|
||||
port = "80";
|
||||
}
|
||||
} else if ((ip = ParseIp(urlarg, -1)) != -1) {
|
||||
host = urlarg;
|
||||
port = "80";
|
||||
} else {
|
||||
ip = servers.n ? ntohl(servers.p[0].addr.sin_addr.s_addr) : INADDR_LOOPBACK;
|
||||
host =
|
||||
gc(xasprintf("%hhu.%hhu.%hhu.%hhu", ip >> 24, ip >> 16, ip >> 8, ip));
|
||||
port =
|
||||
gc(xasprintf("%d", servers.n ? ntohs(servers.p[0].addr.sin_port) : 80));
|
||||
return LuaNilError(L, "invalid host");
|
||||
}
|
||||
if (!IsAcceptableHost(host, -1)) {
|
||||
return LuaNilError(L, "invalid host");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue