From 7468cf34760d72b29e653e650cdf3e9a4e15cf96 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 9 Nov 2017 23:09:05 +0000 Subject: [PATCH] gethostbyname: this crashes with a null pointer trap Fix up what I think was intended --- Applications/netd/gethostbyname.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Applications/netd/gethostbyname.c b/Applications/netd/gethostbyname.c index 188be6bd..75c1cabf 100644 --- a/Applications/netd/gethostbyname.c +++ b/Applications/netd/gethostbyname.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "netdb.h" /* DNS packet header */ @@ -109,6 +110,7 @@ static struct hostent host={ /* static returned hostent struct */ /* Get a host by it's name */ struct hostent *gethostbyname( char *name ){ struct sockaddr_in addr; + static uint32_t av; int x; int tries = 5; int lno=0; @@ -117,8 +119,9 @@ struct hostent *gethostbyname( char *name ){ char *ws = " \f\n\r\t\v"; /* Try to just translate passed stringified IP address */ - x = inet_pton( AF_INET, name, list[0] ); + x = inet_pton( AF_INET, name, &av ); if( x == 1 ){ + list[0] = (void *)&av; list[1] = NULL; return &host; } -- 2.34.1