changeset 1112:8e51a219fc3b

6588160: jaas krb5 client leaks OS-level UDP sockets (all platforms) Reviewed-by: jccollet, chegar
author weijun
date Wed, 01 Oct 2008 10:01:45 +0800
parents fb2ccb7c50c7
children 150a441a305d
files src/share/classes/sun/security/krb5/KrbKdcReq.java src/share/classes/sun/security/krb5/internal/UDPClient.java
diffstat 2 files changed, 24 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/krb5/KrbKdcReq.java	Fri Aug 22 18:48:00 2008 -0700
+++ b/src/share/classes/sun/security/krb5/KrbKdcReq.java	Wed Oct 01 10:01:45 2008 +0800
@@ -274,27 +274,31 @@
                                + ",Attempt =" + i
                                + ", #bytes=" + obuf.length);
                     }
-                    /*
-                     * Send the data to the kdc.
-                     */
+                    try {
+                        /*
+                         * Send the data to the kdc.
+                         */
 
                     kdcClient.send(obuf);
 
-                    /*
-                     * And get a response.
-                     */
-                    try {
-                        ibuf = kdcClient.receive();
-                        break;
-                    } catch (SocketTimeoutException se) {
-                        if (DEBUG) {
-                            System.out.println ("SocketTimeOutException with " +
-                                                "attempt: " + i);
+                        /*
+                         * And get a response.
+                         */
+                        try {
+                            ibuf = kdcClient.receive();
+                            break;
+                        } catch (SocketTimeoutException se) {
+                            if (DEBUG) {
+                                System.out.println ("SocketTimeOutException with " +
+                                                    "attempt: " + i);
+                            }
+                            if (i == DEFAULT_KDC_RETRY_LIMIT) {
+                                ibuf = null;
+                                throw se;
+                            }
                         }
-                        if (i == DEFAULT_KDC_RETRY_LIMIT) {
-                            ibuf = null;
-                            throw se;
-                        }
+                    } finally {
+                        kdcClient.close();
                     }
                 }
             }
--- a/src/share/classes/sun/security/krb5/internal/UDPClient.java	Fri Aug 22 18:48:00 2008 -0700
+++ b/src/share/classes/sun/security/krb5/internal/UDPClient.java	Wed Oct 01 10:01:45 2008 +0800
@@ -93,4 +93,7 @@
         return data;
     }
 
+    public void close() {
+        dgSocket.close();
+    }
 }