diff options
author | dzwdz | 2024-05-25 20:52:11 +0200 |
---|---|---|
committer | dzwdz | 2024-05-25 20:52:11 +0200 |
commit | 5b21be296ea2da40759a5ac0db9ab3eda686c744 (patch) | |
tree | 9cc27cb385035e6333af05677afa75157976b5bb | |
parent | b75b19790bd5dfca42b44e91aa6ebb481ec69444 (diff) |
libc/socket: use the "normal" form of ips
-rw-r--r-- | src/libc/net/socket.c | 11 |
1 files changed, 10 insertions, 1 deletions
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); |