Browse Source

HPCC-21487 Check ldap_search_ext_s result before using it

The ldap_search_ext_s() may return SUCCESS with no result. The
existing CPagedLDAPSearch::requestNextPage() should check the
result before using it.

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 6 years ago
parent
commit
150c1e4628
1 changed files with 11 additions and 0 deletions
  1. 11 0
      system/security/LdapSecurity/ldapconnection.cpp

+ 11 - 0
system/security/LdapSecurity/ldapconnection.cpp

@@ -1213,6 +1213,17 @@ private:
                     }
                     throw MakeStringException(-1, "ldap_search_ext_s failed with 0x%x (%s)",err, ldap_err2string( err ));
                 }
+                if (!m_pPageBlock)
+                {
+                    if (m_pCookie)
+                    {
+                        ber_bvfree(m_pCookie);
+                        m_pCookie = NULL;
+                    }
+                    m_morePages = false;
+                    DBGLOG("CPagedLDAPSearch::requestNextPage: ldap_search_ext_s() returns SUCCESS with no result.");
+                    return false;
+                }
             }
 
             unsigned long l_errcode;