Skip to content
Snippets Groups Projects
Commit e6d37b1c authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Return null from resolve_ip('') and resolve_host('') even on Windows

Defeat the Windows getaddrinfo feature:
If the pNodeName parameter contains an empty string, all registered addresses on the local computer are returned.
parent ddbd0c4f
No related branches found
No related tags found
No related merge requests found
Pipeline #7934 failed
......@@ -51,7 +51,9 @@ var type = {
'random()' : 'number',
'rmdir("")' : 'boolean',
'resolve_host(0)' : 'object', // null
'resolve_host('')' : 'object', // null
'resolve_ip(0)' : 'object', // null
'resolve_ip('')' : 'object', // null
'rot13_translate("")' : 'string',
'sha1_calc("")' : 'string',
'str_has_ctrl("")' : 'boolean',
......
......@@ -4397,7 +4397,13 @@ js_resolve_ip(JSContext *cx, uintN argc, jsval *arglist)
}
if (p == NULL)
return JS_TRUE;
truncsp(p);
if (*p == '\0') {
// Defeat Windows feature:
// If the pNodeName parameter contains an empty string, all registered addresses on the local computer are returned.
free(p);
return JS_TRUE;
}
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_ADDRCONFIG;
hints.ai_socktype = SOCK_STREAM;
......@@ -4461,7 +4467,13 @@ js_resolve_host(JSContext *cx, uintN argc, jsval *arglist)
HANDLE_PENDING(cx, p);
if (p == NULL)
return JS_TRUE;
truncsp(p);
if (*p == '\0') {
// Defeat Windows feature:
// If the pNodeName parameter contains an empty string, all registered addresses on the local computer are returned.
free(p);
return JS_TRUE;
}
rc = JS_SUSPENDREQUEST(cx);
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_NUMERICHOST;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment