diff options
author | Daniel Stenberg <daniel@haxx.se> | 2000-05-29 22:51:13 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2000-05-29 22:51:13 +0000 |
commit | a0ce95e155de68bd5a088a7a539f45aa7134b00b (patch) | |
tree | 4e8c3919e90ce83dbc502b6eeb82668693a46297 /lib/if2ip.c | |
parent | abc751ae1300c7131eb2878a13cec0e24ea2840d (diff) | |
download | curl-a0ce95e155de68bd5a088a7a539f45aa7134b00b.tar.gz |
David LeBlanc's fixes!
Diffstat (limited to 'lib/if2ip.c')
-rw-r--r-- | lib/if2ip.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/if2ip.c b/lib/if2ip.c index 5fa70a68c..557b6fb8c 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -74,9 +74,13 @@ #include <sys/sockio.h> #endif +#ifdef HAVE_INET_NTOA_R +#include "inet_ntoa_r.h" +#endif + #define SYS_ERROR -1 -char *if2ip(char *interface) +char *if2ip(char *interface, char *buf, int buf_size) { int dummy; char *ip=NULL; @@ -101,7 +105,12 @@ char *if2ip(char *interface) struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr; memcpy(&in, &(s->sin_addr.s_addr), sizeof(in)); - ip = (char *)strdup(inet_ntoa(in)); +#if defined(HAVE_INET_NTOA_R) + ip = inet_ntoa_r(in,buf,buf_size); +#else + ip = strncpy(buf,inet_ntoa(in),buf_size); + ip[buf_size - 1] = 0; +#endif } close(dummy); } |