From f36100ef2cbe402b1ae964ab123c97b78d7db8e1 Mon Sep 17 00:00:00 2001 From: vangyzen Date: Thu, 16 Feb 2017 20:50:01 +0000 Subject: [PATCH] Remove inet_ntoa() from the kernel inet_ntoa() cannot be used safely in a multithreaded environment because it uses a static local buffer. Remove it from the kernel. Suggested by: glebius, emaste Reviewed by: gnn MFC after: never Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D9625 --- sys/libkern/inet_ntoa.c | 14 -------------- sys/netinet/in.h | 1 - 2 files changed, 15 deletions(-) diff --git a/sys/libkern/inet_ntoa.c b/sys/libkern/inet_ntoa.c index 767b2d9df175..0c3444c3d0b3 100644 --- a/sys/libkern/inet_ntoa.c +++ b/sys/libkern/inet_ntoa.c @@ -35,20 +35,6 @@ __FBSDID("$FreeBSD$"); #include -char * -inet_ntoa(struct in_addr ina) -{ - static char buf[4*sizeof "123"]; - unsigned char *ucp = (unsigned char *)&ina; - - sprintf(buf, "%d.%d.%d.%d", - ucp[0] & 0xff, - ucp[1] & 0xff, - ucp[2] & 0xff, - ucp[3] & 0xff); - return buf; -} - char * inet_ntoa_r(struct in_addr ina, char *buf) { diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 699023546971..d449b1be296d 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -646,7 +646,6 @@ int in_localaddr(struct in_addr); int in_localip(struct in_addr); int in_ifhasaddr(struct ifnet *, struct in_addr); int inet_aton(const char *, struct in_addr *); /* in libkern */ -char *inet_ntoa(struct in_addr); /* in libkern */ char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */ char *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */ int inet_pton(int af, const char *, void *); /* in libkern */