]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Don't canonicalize hostname in sim_client.c
authorTom Yu <tlyu@mit.edu>
Wed, 30 Dec 2015 22:17:02 +0000 (17:17 -0500)
committerTom Yu <tlyu@mit.edu>
Thu, 7 Jan 2016 03:20:29 +0000 (22:20 -0500)
krb5_mk_req() already canonicalizes the target hostname, so don't try
to use a buffer of size MAXHOSTNAMELEN to canonicalize the hostname
beforehand.  This buffer will be too short for some unusually long
FQDNs.

ticket: 8336 (new)
subject: MAXHOSTNAMELEN is too short for some FQDNs

src/appl/simple/client/sim_client.c

index aaa6446c670c507003b71955e2b860887f2be71d..bd3c38c72aa7a5d7c344f4eca5d84aa3b4dcfc98 100644 (file)
@@ -67,7 +67,6 @@ main(int argc, char *argv[])
     struct servent *serv;
     struct hostent *host;
     char *cp;
-    char full_hname[MAXHOSTNAMELEN];
 #ifdef BROKEN_STREAMS_SOCKETS
     char my_hostname[MAXHOSTNAMELEN];
 #endif
@@ -145,13 +144,6 @@ main(int argc, char *argv[])
         fprintf(stderr, "%s: unknown host\n", hostname);
         exit(1);
     }
-    strncpy(full_hname, host->h_name, sizeof(full_hname)-1);
-    full_hname[sizeof(full_hname)-1] = '\0';
-
-    /* lower-case to get name for "instance" part of service name */
-    for (cp = full_hname; *cp; cp++)
-        if (isupper((int) *cp))
-            *cp = tolower((int) *cp);
 
     /* Set server's address */
     (void) memset(&s_sock, 0, sizeof(s_sock));
@@ -212,7 +204,7 @@ main(int argc, char *argv[])
         exit(1);
     }
 
-    if ((retval = krb5_mk_req(context, &auth_context, 0, service, full_hname,
+    if ((retval = krb5_mk_req(context, &auth_context, 0, service, hostname,
                               &inbuf, ccdef, &packet))) {
         com_err(progname, retval, "while preparing AP_REQ");
         exit(1);