summaryrefslogtreecommitdiff
path: root/gweb/gresolv.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2011-08-31 11:43:46 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2011-09-12 11:40:48 +0200
commita193072b8357a3e39a1a10f93a688df3bfd4fa29 (patch)
treea52f001dfb030561d7c9f31d83c1073d82648c38 /gweb/gresolv.c
parent7598b4c566568aa49ac2f24677cd17592cbd449a (diff)
downloadconnman-a193072b8357a3e39a1a10f93a688df3bfd4fa29.tar.gz
connman-a193072b8357a3e39a1a10f93a688df3bfd4fa29.tar.bz2
connman-a193072b8357a3e39a1a10f93a688df3bfd4fa29.zip
gresolv: Fix buffer size
Make buf just big enough and initialize it in order to get rid of valgrind error (accessing uninitialized memory).
Diffstat (limited to 'gweb/gresolv.c')
-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;