summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2016-12-21 02:18:30 +0100
committerMichael Adam <obnox@samba.org>2017-03-29 23:57:08 +0200
commit46cbe5357cc65e748171ea476b79c70d73976324 (patch)
tree17ad35178ccf867280c7a4e835f45eefba506fd8 /src
parenta71cebb094fc7f4af9b433cb444191de01003ac1 (diff)
network: honour result of inet_ntop in get_ip_string()
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/network.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/network.c b/src/network.c
index a0c4396..7bae20b 100644
--- a/src/network.c
+++ b/src/network.c
@@ -251,6 +251,8 @@ CLEANUP:
*/
const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
{
+ const char *result;
+
assert (sa != NULL);
assert (buf != NULL);
assert (buflen != 0);
@@ -261,7 +263,8 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
{
struct sockaddr_in *sa_in = (struct sockaddr_in *) sa;
- inet_ntop (AF_INET, &sa_in->sin_addr, buf, buflen);
+ result = inet_ntop (AF_INET, &sa_in->sin_addr, buf,
+ buflen);
break;
}
case AF_INET6:
@@ -269,7 +272,8 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
struct sockaddr_in6 *sa_in6 =
(struct sockaddr_in6 *) sa;
- inet_ntop (AF_INET6, &sa_in6->sin6_addr, buf, buflen);
+ result = inet_ntop (AF_INET6, &sa_in6->sin6_addr, buf,
+ buflen);
break;
}
default:
@@ -277,7 +281,7 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
return NULL;
}
- return buf;
+ return result;
}
/*