X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fmts.c;h=de7518c017387ee36448416d90fdbbe5c72789c7;hb=55669aa463e2ce09a1873831bba729d2a29d2188;hp=7941e090dc4c0eb2b39bf93f091f918e5fff2570;hpb=81a21a9a97d8633f6d6231e31fdb6e328d0d3ff2;p=mmh diff --git a/sbr/mts.c b/sbr/mts.c index 7941e09..de7518c 100644 --- a/sbr/mts.c +++ b/sbr/mts.c @@ -31,7 +31,7 @@ /* * static prototypes */ -static char *tailor_value (char *); +static char *tailor_value (unsigned char *); static void getuserinfo (void); /* @@ -172,7 +172,8 @@ static struct bind binds[] = { void mts_init (char *name) { - char *bp, *cp, buffer[BUFSIZ]; + unsigned char *bp; + char *cp, buffer[BUFSIZ]; struct bind *b; FILE *fp; static int inited = 0; @@ -233,7 +234,7 @@ mts_init (char *name) */ static char * -tailor_value (char *s) +tailor_value (unsigned char *s) { int i, r; char *bp; @@ -286,8 +287,7 @@ char * LocalName (void) { static char buffer[BUFSIZ] = ""; - struct hostent *hp; - + struct addrinfo hints, *res; #ifdef HAVE_UNAME struct utsname name; #endif @@ -302,20 +302,24 @@ LocalName (void) if (*localname) { strncpy (buffer, localname, sizeof(buffer)); } else { + memset(buffer, 0, sizeof(buffer)); #ifdef HAVE_UNAME /* first get our local name */ uname (&name); - strncpy (buffer, name.nodename, sizeof(buffer)); + strncpy (buffer, name.nodename, sizeof(buffer) - 1); #else /* first get our local name */ - gethostname (buffer, sizeof(buffer)); + gethostname (buffer, sizeof(buffer) - 1); #endif -#ifdef HAVE_SETHOSTENT - sethostent (1); -#endif /* now fully qualify our name */ - if ((hp = gethostbyname (buffer))) - strncpy (buffer, hp->h_name, sizeof(buffer)); + + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_CANONNAME; + hints.ai_family = PF_UNSPEC; + if (getaddrinfo(buffer, NULL, &hints, &res) == 0) { + strncpy(buffer, res->ai_canonname, sizeof(buffer) - 1); + freeaddrinfo(res); + } } /* @@ -406,7 +410,8 @@ getfullname (void) static void getuserinfo (void) { - register char *cp, *np; + register unsigned char *cp; + register char *np; register struct passwd *pw; #ifdef KPOP