directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [17/18] directory-kerby git commit: Avoiding some NPEs
Date Fri, 21 Jul 2017 15:03:34 GMT
Avoiding some NPEs


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/6bf7ddbc
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/6bf7ddbc
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/6bf7ddbc

Branch: refs/heads/trunk
Commit: 6bf7ddbcd4d31381fb1dff98eb6a2263ace94a65
Parents: 1e30df4
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Fri Jul 21 15:45:10 2017 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Fri Jul 21 15:45:10 2017 +0100

----------------------------------------------------------------------
 .../kerby/kerberos/kerb/gss/impl/GssUtil.java   | 27 ++++++++++++--------
 1 file changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/6bf7ddbc/kerby-kerb/kerb-gssapi/src/main/java/org/apache/kerby/kerberos/kerb/gss/impl/GssUtil.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-gssapi/src/main/java/org/apache/kerby/kerberos/kerb/gss/impl/GssUtil.java
b/kerby-kerb/kerb-gssapi/src/main/java/org/apache/kerby/kerberos/kerb/gss/impl/GssUtil.java
index 372abcb..6b55ea9 100644
--- a/kerby-kerb/kerb-gssapi/src/main/java/org/apache/kerby/kerberos/kerb/gss/impl/GssUtil.java
+++ b/kerby-kerb/kerb-gssapi/src/main/java/org/apache/kerby/kerberos/kerb/gss/impl/GssUtil.java
@@ -261,21 +261,26 @@ public class GssUtil {
         boolean[] flags = ticketFlagsToBooleans(ticketFlags);
 
         Date authTime = new Date(encKdcRepPart.getAuthTime().getTime());
-        Date startTime = new Date(encKdcRepPart.getStartTime().getTime());
+        Date startTime = null;
+        if (encKdcRepPart.getStartTime() != null) {
+            startTime = new Date(encKdcRepPart.getStartTime().getTime());
+        }
         Date endTime = new Date(encKdcRepPart.getEndTime().getTime());
         Date renewTill = new Date(encKdcRepPart.getRenewTill().getTime());
 
         InetAddress[] clientAddresses = null;
-        List<HostAddress> hostAddresses = encKdcRepPart.getCaddr().getElements();
-        if (hostAddresses != null) {
-            int i = 0;
-            clientAddresses = new InetAddress[hostAddresses.size()];
-            for (HostAddress hostAddr : hostAddresses) {
-                try {
-                    InetAddress iAddr = InetAddress.getByAddress(hostAddr.getAddress());
-                    clientAddresses[i++] = iAddr;
-                } catch (UnknownHostException e) {
-                    throw new GSSException(GSSException.FAILURE, -1, "Bad client address");
+        if (encKdcRepPart.getCaddr() != null) {
+            List<HostAddress> hostAddresses = encKdcRepPart.getCaddr().getElements();
+            if (hostAddresses != null) {
+                int i = 0;
+                clientAddresses = new InetAddress[hostAddresses.size()];
+                for (HostAddress hostAddr : hostAddresses) {
+                    try {
+                        InetAddress iAddr = InetAddress.getByAddress(hostAddr.getAddress());
+                        clientAddresses[i++] = iAddr;
+                    } catch (UnknownHostException e) {
+                        throw new GSSException(GSSException.FAILURE, -1, "Bad client address");
+                    }
                 }
             }
         }


Mime
View raw message