osmith has uploaded this change for review. ( https://gerrit.osmocom.org/11520
Change subject: socket.c: fix IP and port buffer sizes ...................................................................... socket.c: fix IP and port buffer sizes Use INET6_ADDRSTRLEN (46) instead of 64 for IP address buffers, and 6 instead of 16 for port buffers (the highest possible port number is 65535). Change-Id: Ia25e2f3277ad2f60df31c08d12f42c1e6d2a14a6 --- M src/socket.c 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/20/11520/1 diff --git a/src/socket.c b/src/socket.c index c7e1c9d..0e17a28 100644 --- a/src/socket.c +++ b/src/socket.c @@ -57,7 +57,7 @@ const char *host, uint16_t port, bool passive) { struct addrinfo hints, *result; - char portbuf[16]; + char portbuf[6]; int rc; snprintf(portbuf, sizeof(portbuf), "%u", port); @@ -698,7 +698,7 @@ { struct sockaddr sa; socklen_t len = sizeof(sa); - char ipbuf[64], portbuf[16]; + char ipbuf[INET6_ADDRSTRLEN], portbuf[6]; int rc; rc = local ? getsockname(fd, &sa, &len) : getpeername(fd, &sa, &len); @@ -769,8 +769,8 @@ */ char *osmo_sock_get_name(void *ctx, int fd) { - char hostbuf_l[64], hostbuf_r[64]; - char portbuf_l[16], portbuf_r[16]; + char hostbuf_l[INET6_ADDRSTRLEN], hostbuf_r[INET6_ADDRSTRLEN]; + char portbuf_l[6], portbuf_r[6]; /* get local */ if (osmo_sock_get_name2(fd, hostbuf_l, sizeof(hostbuf_l), portbuf_l, sizeof(portbuf_l), true)) -- To view, visit https://gerrit.osmocom.org/11520 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Ia25e2f3277ad2f60df31c08d12f42c1e6d2a14a6 Gerrit-Change-Number: 11520 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osm...@sysmocom.de>