https://bugs.openldap.org/show_bug.cgi?id=10563
Issue ID: 10563 Summary: ldap_count_message() returns '1' even with empty LDAPMessage as input. Product: OpenLDAP Version: 2.6.13 Hardware: All OS: All Status: UNCONFIRMED Keywords: needs_review Severity: normal Priority: --- Component: libraries Assignee: bugs@openldap.org Reporter: feh@fehcom.de Target Milestone: ---
Source: libldap/messages.c
The function
int ldap_count_messages( LDAP *ld, LDAPMessage *chain )
given *chain is NULL will return a '1' as result.
Line numbers included:
49 int 50 ldap_count_messages( LDAP *ld, LDAPMessage *chain ) 51 { 52 int i; 53 54 assert( ld != NULL ); 55 assert( LDAP_VALID( ld ) ); 56 57 for ( i = 0; chain != NULL; chain = chain->lm_chain ) { 58 i++; 59 } 60 61 return( i ); 62 }
It would be sufficient to test the LDAP message *chain in the following way before the for loop is executed:
line 56: if (!chain && !*chain) return ( 0 );
--eh.