Fix to properly malloc password buffer, instead of returning a pointer
authorTheodore Tso <tytso@mit.edu>
Wed, 25 Oct 1995 21:09:22 +0000 (21:09 +0000)
committerTheodore Tso <tytso@mit.edu>
Wed, 25 Oct 1995 21:09:22 +0000 (21:09 +0000)
to an automatic variable(!).

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

src/lib/krb5/krb/ChangeLog
src/lib/krb5/krb/in_tkt_pwd.c

index 4576a03b74096d9121e37f15ef1fd93bde458d5d..0be32317187676c8f7d182bbed256e84daccb1ff 100644 (file)
@@ -1,3 +1,8 @@
+Mon Oct 23 17:08:59 1995  Theodore Y. Ts'o  <tytso@dcl>
+
+       * in_tkt_pwd.c (krb5_get_in_tkt_with_password): Fix to properly
+               malloc password buffer.
+
 Mon Oct 23 11:09:56 1995  Ezra Peisach  <epeisach@kangaroo.mit.edu>
 
        * rd_req_dec.c (krb5_rd_req_decoded): For heirarchal cross-realm,
@@ -7,7 +12,6 @@ Mon Oct 23 11:09:56 1995  Ezra Peisach  <epeisach@kangaroo.mit.edu>
                and then there is an error, make sure return pointer is not
                looking at freed memory.
 
-
 Fri Oct  6 22:04:42 1995  Theodore Y. Ts'o  <tytso@dcl>
 
        * Makefile.in: Remove ##DOS!include of config/windows.in.
index e73b1898d6dd60986d5a206164792e905878f413..9c4690cf17a551290e14a1c67ac9d3ed26b9705a 100644 (file)
@@ -48,9 +48,8 @@ pwd_keyproc(context, type, salt, keyseed, key)
 {
     krb5_error_code retval;
     krb5_encrypt_block eblock;
-    char pwdbuf[BUFSIZ];
     krb5_data * password;
-    int pwsize = sizeof(pwdbuf);
+    int pwsize;
 
     if (!valid_enctype(type))
        return KRB5_PROG_ETYPE_NOSUPP;
@@ -60,12 +59,15 @@ pwd_keyproc(context, type, salt, keyseed, key)
     password = (krb5_data *)keyseed;
 
     if (!password->length) {
+       pwsize = BUFSIZ;
+       if ((password->data = malloc(password->length)) == NULL)
+           return ENOMEM;
+       
        if ((retval = krb5_read_password(context, krb5_default_pwd_prompt1, 0,
-                                        pwdbuf, &pwsize))) {
+                                        password->data, &pwsize))) {
            return retval;
        }
-        password->length = pwsize;
-        password->data = pwdbuf;
+       password->length = pwsize;
     }
 
     if (!(*key = (krb5_keyblock *)malloc(sizeof(**key))))
@@ -122,6 +124,12 @@ krb5_get_in_tkt_with_password(context, options, addrs, ktypes, pre_auth_types,
                             pwd_keyproc, (krb5_pointer) &data,
                             krb5_kdc_rep_decrypt_proc, 0,
                             creds, ccache, ret_as_reply);
+
+    if ((password == NULL) && (data.data)) {
+       memset(data.data, 0, strlen(data.data));
+       free(data.data);
+    }
+
     return retval;
 }