From f0196a13af2d58cd4f48ba0817c568ace4795cdc Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 19 Oct 2012 16:27:29 +0200 Subject: login: stop using MAXHOSTNAMELEN Signed-off-by: Karel Zak --- login-utils/login.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'login-utils/login.c') diff --git a/login-utils/login.c b/login-utils/login.c index 8ae5266f1..f37718753 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -109,7 +109,7 @@ struct login_context { char vcsan[VCS_PATH_MAX]; #endif - char thishost[MAXHOSTNAMELEN + 1]; /* this machine */ + char *thishost; /* this machine */ char *thisdomain; /* this machine domain */ char *hostname; /* remote machine */ char hostaddress[16]; /* remote address */ @@ -209,13 +209,13 @@ static void __attribute__ ((__noreturn__)) sleepexit(int eval) static const char *get_thishost(struct login_context *cxt, const char **domain) { - if (!*cxt->thishost) { - if (gethostname(cxt->thishost, sizeof(cxt->thishost))) { + if (!cxt->thishost) { + cxt->thishost = xgethostname(); + if (!cxt->thishost) { if (domain) *domain = NULL; return NULL; } - cxt->thishost[sizeof(cxt->thishost) -1] = '\0'; cxt->thisdomain = strchr(cxt->thishost, '.'); if (cxt->thisdomain) *cxt->thisdomain++ = '\0'; -- cgit v1.2.3-55-g7522