summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-06-07 07:36:59 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-06-07 13:02:21 +0200
commite744c36c3f4b81c1a0d30200491af9e93839ea7e (patch)
tree31cfb8685a8970f59b999f5659ab4ce1d1b5d029
parent9b035a0a4a927007e88b7347782668557903bb31 (diff)
downloadrtems-e744c36c3f4b81c1a0d30200491af9e93839ea7e.tar.bz2
network: Use inet_ntoa_r()
Update #2833.
-rw-r--r--cpukit/libnetworking/netinet/if_ether.c17
-rw-r--r--cpukit/libnetworking/netinet/ip_input.c7
-rw-r--r--cpukit/libnetworking/netinet/tcp_input.c8
-rw-r--r--cpukit/libnetworking/netinet/udp_usrreq.c8
-rw-r--r--cpukit/libnetworking/nfs/bootp_subr.c3
-rw-r--r--cpukit/libnetworking/rtems/mkrootfs.c4
-rw-r--r--cpukit/libnetworking/rtems/rtems_dhcp.c3
7 files changed, 29 insertions, 21 deletions
diff --git a/cpukit/libnetworking/netinet/if_ether.c b/cpukit/libnetworking/netinet/if_ether.c
index 1a5a7bfe17..db703b4c60 100644
--- a/cpukit/libnetworking/netinet/if_ether.c
+++ b/cpukit/libnetworking/netinet/if_ether.c
@@ -343,8 +343,9 @@ arpresolve(
rt = la->la_rt;
}
if (la == 0 || rt == 0) {
+ char addrbuf[INET_ADDRSTRLEN];
log(LOG_DEBUG, "arpresolve: can't allocate llinfo for %s\n",
- inet_ntoa(SIN(dst)->sin_addr));
+ inet_ntoa_r(SIN(dst)->sin_addr, addrbuf));
m_freem(m);
return (0);
}
@@ -449,6 +450,7 @@ in_arpinput(struct mbuf *m)
struct sockaddr sa;
struct in_addr isaddr, itaddr, myaddr;
int op;
+ char addrbuf[INET_ADDRSTRLEN];
ea = mtod(m, struct ether_arp *);
op = ntohs(ea->arp_op);
@@ -475,14 +477,14 @@ in_arpinput(struct mbuf *m)
sizeof (ea->arp_sha))) {
log(LOG_ERR,
"arp: ether address is broadcast for IP address %s!\n",
- inet_ntoa(isaddr));
+ inet_ntoa_r(isaddr, addrbuf));
m_freem(m);
return;
}
if (isaddr.s_addr == myaddr.s_addr) {
log(LOG_ERR,
"arp: %6D is using my IP address %s!\n",
- ea->arp_sha, ":", inet_ntoa(isaddr));
+ ea->arp_sha, ":", inet_ntoa_r(isaddr, addrbuf));
itaddr = myaddr;
goto reply;
}
@@ -491,8 +493,8 @@ in_arpinput(struct mbuf *m)
if (sdl->sdl_alen &&
bcmp((caddr_t)ea->arp_sha, LLADDR(sdl), sdl->sdl_alen))
log(LOG_INFO, "arp: %s moved from %6D to %6D\n",
- inet_ntoa(isaddr), (u_char *)LLADDR(sdl), ":",
- ea->arp_sha, ":");
+ inet_ntoa_r(isaddr, addrbuf),
+ (u_char *)LLADDR(sdl), ":", ea->arp_sha, ":");
(void)memcpy(LLADDR(sdl), ea->arp_sha, sizeof(ea->arp_sha));
sdl->sdl_alen = sizeof(ea->arp_sha);
if (rt->rt_expire)
@@ -549,7 +551,7 @@ reply:
rtfree(rt);
#ifdef DEBUG_PROXY
printf("arp: proxying for %s\n",
- inet_ntoa(itaddr));
+ inet_ntoa_r(itaddr, addrbuf));
#endif
} else {
rt = la->la_rt;
@@ -619,8 +621,9 @@ arplookup(u_long addr, int create, int proxy)
why = "gateway route is not ours";
if (why && create) {
+ char addrbuf[INET_ADDRSTRLEN];
log(LOG_DEBUG, "arplookup %s failed: %s\n",
- inet_ntoa(sin.sin_addr), why);
+ inet_ntoa_r(sin.sin_addr, addrbuf), why);
return 0;
} else if (why) {
return 0;
diff --git a/cpukit/libnetworking/netinet/ip_input.c b/cpukit/libnetworking/netinet/ip_input.c
index 65eaa07250..e61ba26aa9 100644
--- a/cpukit/libnetworking/netinet/ip_input.c
+++ b/cpukit/libnetworking/netinet/ip_input.c
@@ -973,13 +973,14 @@ ip_dooptions(struct mbuf *m)
}
if (!ip_dosourceroute) {
- char buf[4*sizeof "123"];
+ char buf0[INET_ADDRSTRLEN];
+ char buf1[INET_ADDRSTRLEN];
nosourcerouting:
- strcpy(buf, inet_ntoa(ip->ip_dst));
log(LOG_WARNING,
"attempted source route from %s to %s\n",
- inet_ntoa(ip->ip_src), buf);
+ inet_ntoa_r(ip->ip_dst, buf0),
+ inet_ntoa_r(ip->ip_src, buf1));
type = ICMP_UNREACH;
code = ICMP_UNREACH_SRCFAIL;
goto bad;
diff --git a/cpukit/libnetworking/netinet/tcp_input.c b/cpukit/libnetworking/netinet/tcp_input.c
index 49144c217f..caedc649fc 100644
--- a/cpukit/libnetworking/netinet/tcp_input.c
+++ b/cpukit/libnetworking/netinet/tcp_input.c
@@ -380,13 +380,13 @@ findpcb:
*/
if (inp == NULL) {
if (log_in_vain && tiflags & TH_SYN) {
- char buf[4*sizeof "123"];
+ char buf0[INET_ADDRSTRLEN];
+ char buf1[INET_ADDRSTRLEN];
- strcpy(buf, inet_ntoa(ti->ti_dst));
log(LOG_INFO, "Connection attempt to TCP %s:%d"
" from %s:%d\n",
- buf, ntohs(ti->ti_dport),
- inet_ntoa(ti->ti_src), ntohs(ti->ti_sport));
+ inet_ntoa_r(ti->ti_dst, buf0), ntohs(ti->ti_dport),
+ inet_ntoa_r(ti->ti_src, buf1), ntohs(ti->ti_sport));
}
goto dropwithreset;
}
diff --git a/cpukit/libnetworking/netinet/udp_usrreq.c b/cpukit/libnetworking/netinet/udp_usrreq.c
index 1125c45880..621f97d063 100644
--- a/cpukit/libnetworking/netinet/udp_usrreq.c
+++ b/cpukit/libnetworking/netinet/udp_usrreq.c
@@ -281,13 +281,13 @@ udp_input(struct mbuf *m, int iphlen)
ip->ip_dst, uh->uh_dport, 1);
if (inp == NULL) {
if (log_in_vain) {
- char buf[4*sizeof "123"];
+ char buf0[INET_ADDRSTRLEN];
+ char buf1[INET_ADDRSTRLEN];
- strcpy(buf, inet_ntoa(ip->ip_dst));
log(LOG_INFO, "Connection attempt to UDP %s:%d"
" from %s:%d\n",
- buf, ntohs(uh->uh_dport),
- inet_ntoa(ip->ip_src), ntohs(uh->uh_sport));
+ inet_ntoa_r(ip->ip_dst, buf0), ntohs(uh->uh_dport),
+ inet_ntoa_r(ip->ip_src, buf1), ntohs(uh->uh_sport));
}
udpstat.udps_noport++;
if (m->m_flags & (M_BCAST | M_MCAST)) {
diff --git a/cpukit/libnetworking/nfs/bootp_subr.c b/cpukit/libnetworking/nfs/bootp_subr.c
index 22d453faf2..484a6b5d72 100644
--- a/cpukit/libnetworking/nfs/bootp_subr.c
+++ b/cpukit/libnetworking/nfs/bootp_subr.c
@@ -1184,8 +1184,9 @@ bootpc_init(bool update_files, bool forever)
}
for (i = 0; i < rtems_bsdnet_nameserver_count; i++) {
+ char addrbuf[INET_ADDRSTRLEN];
strcpy(buf, "nameserver ");
- strcat(buf, inet_ntoa(rtems_bsdnet_nameserver[i]));
+ strcat(buf, inet_ntoa_r(rtems_bsdnet_nameserver[i], addrbuf));
strcat(buf, "\n");
if (rtems_rootfs_file_append ("/etc/resolv.conf", MKFILE_MODE, 1, bufl))
break;
diff --git a/cpukit/libnetworking/rtems/mkrootfs.c b/cpukit/libnetworking/rtems/mkrootfs.c
index aaf670b6b1..c110a62b0a 100644
--- a/cpukit/libnetworking/rtems/mkrootfs.c
+++ b/cpukit/libnetworking/rtems/mkrootfs.c
@@ -177,7 +177,9 @@ rtems_rootfs_append_host_rec (in_addr_t cip,
if (cname && strlen (cname))
{
- snprintf (bufp, sizeof (buf), "%s\t\t%s", inet_ntoa (ip), cname);
+ char addrbuf[INET_ADDRSTRLEN];
+
+ snprintf (bufp, sizeof (buf), "%s\t\t%s", inet_ntoa_r (ip, addrbuf), cname);
bufp += strlen (buf);
if (dname && strlen (dname))
diff --git a/cpukit/libnetworking/rtems/rtems_dhcp.c b/cpukit/libnetworking/rtems/rtems_dhcp.c
index 5f5515c847..fa7589071d 100644
--- a/cpukit/libnetworking/rtems/rtems_dhcp.c
+++ b/cpukit/libnetworking/rtems/rtems_dhcp.c
@@ -1132,8 +1132,9 @@ dhcp_init (int update_files)
}
for (i = 0; i < rtems_bsdnet_nameserver_count; i++) {
+ char addrbuf[INET_ADDRSTRLEN];
strcpy(buf, "nameserver ");
- strcat(buf, inet_ntoa(rtems_bsdnet_ntpserver[i]));
+ strcat(buf, inet_ntoa_r(rtems_bsdnet_ntpserver[i], addrbuf));
strcat(buf, "\n");
if (rtems_rootfs_file_append ("/etc/resolv.conf", MKFILE_MODE, 1, bufl))
break;