summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2024-05-05 00:29:06 +0200
committerJo-Philipp Wich <jo@mein.io>2024-05-17 15:46:47 +0200
commit3a586dc7ddbeeb14c25da5439a6c4e989b856f6e (patch)
treed915f6667f645187fad159e432100a271d698c4d /lib
parent3938645ad9e3a9fe1e6de6eaa64c071e59d3ff22 (diff)
socket: improve uc_socket_connect() behavior
Treat address strings containing slashes as AF_UNIX paths and do not attempt to resolve them. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib')
-rw-r--r--lib/socket.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/socket.c b/lib/socket.c
index e313f8b..7fc56c8 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -2156,6 +2156,14 @@ uc_socket_poll(uc_vm_t *vm, size_t nargs)
ok_return(rv);
}
+static bool
+should_resolve(uc_value_t *host)
+{
+ char *s = ucv_string_get(host);
+
+ return (s != NULL && memchr(s, '/', ucv_string_length(host)) == NULL);
+}
+
/**
* Creates a network socket and connects it to the specified host and service.
*
@@ -2239,7 +2247,7 @@ uc_socket_connect(uc_vm_t *vm, size_t nargs)
ai_hints = hints
? (struct addrinfo *)uv_to_struct(hints, &st_addrinfo) : NULL;
- if (ucv_type(host) == UC_STRING) {
+ if (should_resolve(host)) {
char *servstr = (ucv_type(serv) != UC_STRING)
? ucv_to_string(vm, serv) : NULL;