krb5_free_pwd_sequences only frees first element
authorEzra Peisach <epeisach@mit.edu>
Wed, 23 Apr 2003 20:28:23 +0000 (20:28 +0000)
committerEzra Peisach <epeisach@mit.edu>
Wed, 23 Apr 2003 20:28:23 +0000 (20:28 +0000)
* kfree.c (krb5_free_pwd_sequences): Actually free the entire
sequence of passwd_phase_elements and not just the first one.

In our tree, this code is only used by krb5_free_pwd_data() which is
subsequently not used anywhere else. Perhaps all code pertaining to pwd
data (asn.1 decoders, encoders, etc. should be removed)

ticket: new
component: krb5-libs
target_version: 1.3
tags: pullup

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

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

index 6a48ed281375f5ddf403922daa732b6b0f7a08c7..bdb37203d9027c91090fd3b86d4cb2b1c8691af5 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-23  Ezra Peisach  <epeisach@mit.edu>
+
+       * kfree.c (krb5_free_pwd_sequences): Actually free the entire
+       sequence of passwd_phase_elements and not just the first one.
+
 2003-04-13  Ken Raeburn  <raeburn@mit.edu>
 
        * init_ctx.c (DEFAULT_ETYPE_LIST): Add AES with 256 bits at the
index 46d485d32085e4a026ae01bd33e3826a1f889e2f..edb0699eb3c09658220a3786a7f86e8c3e2c31ca 100644 (file)
@@ -429,14 +429,20 @@ krb5_free_pwd_data(krb5_context context, krb5_pwd_data *val)
 void KRB5_CALLCONV
 krb5_free_pwd_sequences(krb5_context context, passwd_phrase_element **val)
 {
-    if ((*val)->passwd) {
-       krb5_xfree((*val)->passwd);
-       (*val)->passwd = 0;
-    }
-    if ((*val)->phrase) {
-       krb5_xfree((*val)->phrase);
-       (*val)->phrase = 0;
+    register passwd_phrase_element **temp;
+
+    for (temp = val; *temp; temp++) {
+       if ((*temp)->passwd) {
+          krb5_xfree((*temp)->passwd);
+          (*temp)->passwd = 0;
+       }
+       if ((*temp)->phrase) {
+          krb5_xfree((*temp)->phrase);
+          (*temp)->phrase = 0;
+       }
+       krb5_xfree(*temp);
     }
+    krb5_xfree(val);
 }