Fix bug where kinit would core dump if given a really long principal
authorTheodore Tso <tytso@mit.edu>
Thu, 29 May 1997 19:44:14 +0000 (19:44 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 29 May 1997 19:44:14 +0000 (19:44 +0000)
name.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10090 dc483132-0cff-0310-8789-dd5450dbe970

src/clients/kinit/ChangeLog
src/clients/kinit/kinit.c

index 3aa66c281f6e1847e443708fefae659bdfee51b9..500bbc7a8635d415c37ae55b593b9c54db11ce4d 100644 (file)
@@ -1,3 +1,8 @@
+Thu May 29 19:39:08 1997  Theodore Y. Ts'o  <tytso@mit.edu>
+
+       * kinit.c (main): Fix bug where kinit would core dump if given a
+               really long principal name.
+
 Tue Feb 25 00:29:46 1997  Richard Basch  <basch@lehman.com>
 
        * kinit.c: Moved krb5_read_password back into the library (win32)
index bae27955d5d095ec00d9be3ea7568ac8de9568fd..bc0a1eafe137b09a9df96132533a0a85fba2e2b5 100644 (file)
@@ -89,7 +89,7 @@ main(argc, argv)
     krb5_keytab keytab = NULL;
     struct passwd *pw = 0;
     int pwsize;
-    char password[255], *client_name, prompt[255];
+    char password[255], *client_name, prompt[1024];
 
     code = krb5_init_context(&kcontext);
     if (code) {
@@ -280,7 +280,7 @@ main(argc, argv)
              exit(1);
         }
     } else {
-        if (code = krb5_parse_name(kcontext, service_name, &server)) {
+        if ((code = krb5_parse_name(kcontext, service_name, &server))) {
              com_err(argv[0], code, "while parsing service name %s",
                      service_name);
              exit(1);
@@ -331,7 +331,8 @@ main(argc, argv)
     if (!use_keytab)
 #endif
     {
-        (void) sprintf(prompt,"Password for %s: ", (char *) client_name);
+        (void) sprintf(prompt, "Password for %.*s: ",
+                       sizeof(prompt)-32, (char *) client_name);
 
         pwsize = sizeof(password);