krb5_rd_rep leaks subkeys
authorTom Yu <tlyu@mit.edu>
Fri, 13 Jun 2003 21:45:30 +0000 (21:45 +0000)
committerTom Yu <tlyu@mit.edu>
Fri, 13 Jun 2003 21:45:30 +0000 (21:45 +0000)
* rd_rep.c (krb5_rd_rep): Free subkeys before replacing them, if
needed.  This avoids a memory leak.

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

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

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

index 3b5287f0c469293aef96e725e7c6535f73294228..b7aab3c0d2fd89571a9368cf6252d98b045beb53 100644 (file)
@@ -1,3 +1,8 @@
+2003-06-13  Tom Yu  <tlyu@mit.edu>
+
+       * rd_rep.c (krb5_rd_rep): Free subkeys before replacing them, if
+       needed.  This avoids a memory leak.
+
 2003-06-11  Tom Yu  <tlyu@mit.edu>
 
        * srv_rcache.c (krb5_get_server_rcache): Octal escapes begin with
index 50ce51331efe5bc9c2fe9cd50ec8bb4cd8618c33..80192294e8bd3ac795238125181d677f1eed6ba9 100644 (file)
@@ -81,10 +81,18 @@ krb5_rd_rep(krb5_context context, krb5_auth_context auth_context, const krb5_dat
 
     /* Set auth subkey */
     if ((*repl)->subkey) {
+       if (auth_context->recv_subkey) {
+           krb5_free_keyblock(context, auth_context->recv_subkey);
+           auth_context->recv_subkey = NULL;
+       }
        retval = krb5_copy_keyblock(context, (*repl)->subkey,
                                    &auth_context->recv_subkey);
        if (retval)
            goto clean_scratch;
+       if (auth_context->send_subkey) {
+           krb5_free_keyblock(context, auth_context->send_subkey);
+           auth_context->send_subkey = NULL;
+       }
        retval = krb5_copy_keyblock(context, (*repl)->subkey,
                                    &auth_context->send_subkey);
        if (retval) {