Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145980228
D45601.id140673.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D45601.id140673.diff
View Options
diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c
--- a/usr.sbin/ppp/defs.c
+++ b/usr.sbin/ppp/defs.c
@@ -144,13 +144,18 @@
break;
if (*ptr == '\0') {
- struct hostent *hp;
-
- hp = gethostbyname(cp);
- if (hp && hp->h_addrtype == AF_INET)
- memcpy(&ipaddr, hp->h_addr, hp->h_length);
- else
+ struct addrinfo *res;
+
+ if (getaddrinfo(cp, NULL, &(struct addrinfo){
+ .ai_family = AF_INET
+ }, &res) == 0) {
+ memcpy(&ipaddr, &((struct sockaddr_in *)res->ai_addr)->sin_addr,
+ sizeof(struct in_addr));
+ freeaddrinfo(res);
+ }
+ else {
ipaddr.s_addr = INADDR_NONE;
+ }
} else
ipaddr.s_addr = INADDR_NONE;
}
diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c
--- a/usr.sbin/ppp/ipcp.c
+++ b/usr.sbin/ppp/ipcp.c
@@ -447,7 +447,7 @@
ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l,
const struct fsm_parent *parent)
{
- struct hostent *hp;
+ struct addrinfo *res;
struct in_addr host;
char name[MAXHOSTNAMELEN];
static const char * const timer_names[] =
@@ -463,9 +463,13 @@
host.s_addr = htonl(INADDR_LOOPBACK);
ipcp->cfg.netmask.s_addr = INADDR_ANY;
if (gethostname(name, sizeof name) == 0) {
- hp = gethostbyname(name);
- if (hp && hp->h_addrtype == AF_INET && hp->h_length == sizeof host.s_addr)
- memcpy(&host.s_addr, hp->h_addr, sizeof host.s_addr);
+ if (getaddrinfo(name, NULL, &(struct addrinfo){
+ .ai_family = AF_INET
+ }, &res) == 0) {
+ memcpy(&host.s_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr,
+ sizeof(host.s_addr));
+ freeaddrinfo(res);
+ }
}
ncprange_setip4(&ipcp->cfg.my_range, host, ipcp->cfg.netmask);
ncprange_setip4(&ipcp->cfg.peer_range, ipcp->cfg.netmask, ipcp->cfg.netmask);
diff --git a/usr.sbin/ppp/nat_cmd.c b/usr.sbin/ppp/nat_cmd.c
--- a/usr.sbin/ppp/nat_cmd.c
+++ b/usr.sbin/ppp/nat_cmd.c
@@ -306,17 +306,19 @@
static int
StrToAddr(const char *str, struct in_addr *addr)
{
- struct hostent *hp;
+ struct addrinfo *res;
if (inet_aton(str, addr))
return 0;
- hp = gethostbyname(str);
- if (!hp) {
+ if (getaddrinfo(str, NULL, &(struct addrinfo){
+ .ai_family = AF_INET
+ }, &res) != 0 ) {
log_Printf(LogWARN, "StrToAddr: Unknown host %s.\n", str);
return -1;
}
- *addr = *((struct in_addr *) hp->h_addr);
+ *addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr;
+ freeaddrinfo(res);
return 0;
}
diff --git a/usr.sbin/ppp/radius.c b/usr.sbin/ppp/radius.c
--- a/usr.sbin/ppp/radius.c
+++ b/usr.sbin/ppp/radius.c
@@ -899,7 +899,7 @@
const char *what = "questionable"; /* silence warnings! */
char *mac_addr;
int got;
- struct hostent *hp;
+ struct addrinfo *res;
struct in_addr hostaddr;
#ifndef NODES
struct mschap_response msresp;
@@ -1023,8 +1023,11 @@
log_Printf(LogERROR, "rad_put: gethostname(): %s\n", strerror(errno));
else {
if (Enabled(authp->physical->dl->bundle, OPT_NAS_IP_ADDRESS) &&
- (hp = gethostbyname(hostname)) != NULL) {
- hostaddr.s_addr = *(u_long *)hp->h_addr;
+ getaddrinfo(hostname, NULL, &(struct addrinfo){
+ .ai_family = AF_INET
+ }, &res) == 0) {
+ hostaddr.s_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr;
+ freeaddrinfo(res);
if (rad_put_addr(r->cx.rad, RAD_NAS_IP_ADDRESS, hostaddr) != 0) {
log_Printf(LogERROR, "rad_put: rad_put_string: %s\n",
rad_strerror(r->cx.rad));
@@ -1100,7 +1103,7 @@
int got;
char hostname[MAXHOSTNAMELEN];
char *mac_addr;
- struct hostent *hp;
+ struct addrinfo *res;
struct in_addr hostaddr;
if (!*r->cfg.file)
@@ -1208,8 +1211,11 @@
log_Printf(LogERROR, "rad_put: gethostname(): %s\n", strerror(errno));
else {
if (Enabled(dl->bundle, OPT_NAS_IP_ADDRESS) &&
- (hp = gethostbyname(hostname)) != NULL) {
- hostaddr.s_addr = *(u_long *)hp->h_addr;
+ getaddrinfo(hostname, NULL, &(struct addrinfo){
+ .ai_family = AF_INET
+ }, &res) == 0) {
+ hostaddr.s_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr;
+ freeaddrinfo(res);
if (rad_put_addr(r->cx.rad, RAD_NAS_IP_ADDRESS, hostaddr) != 0) {
log_Printf(LogERROR, "rad_put: rad_put_string: %s\n",
rad_strerror(r->cx.rad));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Feb 27, 5:40 PM (21 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29037500
Default Alt Text
D45601.id140673.diff (4 KB)
Attached To
Mode
D45601: ppp: remove gethostby*() calls
Attached
Detach File
Event Timeline
Log In to Comment