]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: stop using MAXHOSTNAMELEN
authorKarel Zak <kzak@redhat.com>
Fri, 19 Oct 2012 14:27:29 +0000 (16:27 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 19 Oct 2012 14:27:29 +0000 (16:27 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index 8ae5266f1370aab8c5cb731672457cf302069604..f37718753f4ef10fc33d92abb4d1a4dc84a18818 100644 (file)
@@ -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';