aboutsummaryrefslogtreecommitdiff
path: root/lib/if2ip.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/if2ip.c')
-rw-r--r--lib/if2ip.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/if2ip.c b/lib/if2ip.c
index 558e30f15..cc191201e 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -95,6 +95,7 @@ char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size)
curl_strequal(iface->ifa_name, interf)) {
void *addr;
char scope[12]="";
+ char ipstr[64];
#ifdef ENABLE_IPV6
if(af == AF_INET6) {
unsigned int scopeid = 0;
@@ -109,8 +110,9 @@ char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size)
else
#endif
addr = &((struct sockaddr_in *)iface->ifa_addr)->sin_addr;
- ip = (char *) Curl_inet_ntop(af, addr, buf, buf_size);
- strlcat(buf, scope, buf_size);
+ ip = (char *) Curl_inet_ntop(af, addr, ipstr, sizeof(ipstr));
+ snprintf(buf, buf_size, "%s%s", ip, scope);
+ ip = buf;
break;
}
}