From 5b21be296ea2da40759a5ac0db9ab3eda686c744 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 25 May 2024 20:52:11 +0200 Subject: libc/socket: use the "normal" form of ips --- src/libc/net/socket.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/libc') diff --git a/src/libc/net/socket.c b/src/libc/net/socket.c index 04d73f4..ce74029 100644 --- a/src/libc/net/socket.c +++ b/src/libc/net/socket.c @@ -49,7 +49,16 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { ip = ntohl(addr4->sin_addr.s_addr); port = ntohs(addr4->sin_port); - if (snprintf(buf, 256, "/net/connect/0/%ld/tcp/%d", ip, port) >= 256) { + if ( + snprintf(buf, sizeof(buf), + "/net/connect/0.0.0.0/%d.%d.%d.%d/tcp/%d", + (ip >> 24) & 0xFF, + (ip >> 16) & 0xFF, + (ip >> 8) & 0xFF, + (ip ) & 0xFF, + port + ) >= 256 + ) { return errno = EGENERIC, -1; } newfd = camellia_open(buf, OPEN_READ | OPEN_WRITE); -- cgit v1.2.3