commit a752450545305bad80a9f4b8843ae0f7cb0aefbd
parent b1acd6f00e076ee63e2748fc2a94dba90000e542
Author: sin <sin@2f30.org>
Date: Tue, 5 Jun 2012 18:54:33 +0100
sscall: Ensure the `host' buffer is set to something sensible
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sscall.c b/sscall.c
@@ -438,8 +438,10 @@ main(int argc, char *argv[])
ret = getnameinfo((struct sockaddr *)&their_addr,
addr_len, host,
sizeof(host), NULL, 0, 0);
- if (ret < 0)
+ if (ret < 0) {
warn("getnameinfo");
+ snprintf(host, sizeof(host), "unknown");
+ }
printf("Received %zd bytes from %s\n",
bytes, host);
}