summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gweb/gresolv.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gweb/gresolv.c b/gweb/gresolv.c
index d857e01d..0e7a755b 100644
--- a/gweb/gresolv.c
+++ b/gweb/gresolv.c
@@ -453,7 +453,7 @@ static void rfc3484_sort_results(struct resolv_lookup *lookup)
static void sort_and_return_results(struct resolv_lookup *lookup)
{
- char buf[100];
+ char buf[INET6_ADDRSTRLEN + 1];
GResolvResultStatus status;
char **results = g_try_new0(char *, lookup->nr_results + 1);
int i, n = 0;
@@ -461,18 +461,20 @@ static void sort_and_return_results(struct resolv_lookup *lookup)
if (!results)
return;
+ memset(buf, 0, INET6_ADDRSTRLEN + 1);
+
rfc3484_sort_results(lookup);
for (i = 0; i < lookup->nr_results; i++) {
if (lookup->results[i].dst.sa.sa_family == AF_INET) {
if (inet_ntop(AF_INET,
&lookup->results[i].dst.sin.sin_addr,
- buf, sizeof(buf)) == NULL)
+ buf, sizeof(buf) - 1) == NULL)
continue;
} else if (lookup->results[i].dst.sa.sa_family == AF_INET6) {
if (inet_ntop(AF_INET6,
&lookup->results[i].dst.sin6.sin6_addr,
- buf, sizeof(buf)) == NULL)
+ buf, sizeof(buf) - 1) == NULL)
continue;
} else
continue;