diff options
author | Abhishek Koneru <akoneru@redhat.com> | 2012-06-06 16:55:54 -0400 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-06-14 17:14:19 -0500 |
commit | c53ca291e21761f1de5417ef596afba395a7f5d1 (patch) | |
tree | 47a0cd8ecd9d36d414d9230282704e9f784d0a71 /base/common/src/com/netscape/cms/servlet/csadmin | |
parent | 084a8cd360c7508febde06415d727d7d247b16ad (diff) | |
download | pki-c53ca291e21761f1de5417ef596afba395a7f5d1.tar.gz pki-c53ca291e21761f1de5417ef596afba395a7f5d1.tar.xz pki-c53ca291e21761f1de5417ef596afba395a7f5d1.zip |
Fixes for NULL_RETURNS Coverity Issues - Part 2
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/csadmin')
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java b/base/common/src/com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java index b9932722e..ff9ab5eba 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java @@ -192,7 +192,11 @@ public class LDAPSecurityDomainSessionTable LDAPSearchResults res = conn.search(sessionsdn, LDAPv2.SCOPE_SUB, filter, attrs, false); while (res.hasMoreElements()) { LDAPEntry entry = res.next(); - ret.add(entry.getAttribute("cn").getStringValueArray()[0]); + LDAPAttribute sid = entry.getAttribute("cn"); + if (sid == null) { + throw new Exception("Invalid LDAP Entry." + entry.getDN() + " No session id(cn)."); + } + ret.add(sid.getStringValueArray()[0]); } } catch (LDAPException e) { switch (e.getLDAPResultCode()) { @@ -228,10 +232,14 @@ public class LDAPSecurityDomainSessionTable LDAPSearchResults res = conn.search(sessionsdn, LDAPv2.SCOPE_SUB, filter, attrs, false); if (res.getCount() > 0) { LDAPEntry entry = res.next(); - ret = entry.getAttribute(attr).getStringValueArray()[0]; + LDAPAttribute searchAttribute = entry.getAttribute(attr); + if (searchAttribute == null) { + throw new Exception("No Attribute " + attr + " for this session in LDAPEntry "+entry.getDN()); + } + ret = searchAttribute.getStringValueArray()[0]; } } catch (Exception e) { - CMS.debug("SecurityDomainSessionTable: unable to query session " + sessionId + ": " + e); + CMS.debug("SecurityDomainSessionTable: unable to query session " + sessionId + ": " + e.getMessage()); } try { |