From 4b6a25ac068e6dd686d1aae15f1d668b60c735c1 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Tue, 17 Nov 2009 01:44:21 +0530 Subject: Use snprintf() with size of the portstr buf --- src/sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sock.c b/src/sock.c index a7bba15..d9acd5b 100644 --- a/src/sock.c +++ b/src/sock.c @@ -167,7 +167,7 @@ int socket_blocking (int sock) int listen_sock (uint16_t port, socklen_t * addrlen) { struct addrinfo hints, *result, *rp; - char portstr[32]; + char portstr[6]; int listenfd; const int on = 1; @@ -178,7 +178,7 @@ int listen_sock (uint16_t port, socklen_t * addrlen) hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - sprintf (portstr, "%6d", port); + snprintf (portstr, sizeof (portstr), "%d", port); if (getaddrinfo (config.ipAddr, portstr, &hints, &result) != 0) { log_message (LOG_ERR, -- cgit v1.2.3