From da739cfe918b608a0ae24ef1e8102e3f5fd58d6c Mon Sep 17 00:00:00 2001 From: Howard Chu <hyc@symas.com> Date: Sun, 18 Jan 2015 14:27:19 +0000 Subject: [PATCH] Minor cleanup (coverity) --- libraries/libldap/cyrus.c | 1 + libraries/libldap/dnssrv.c | 4 +++- libraries/libldap/filter.c | 4 +--- libraries/libldap/request.c | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index 7c3ccbda4b..30969adcff 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -1149,6 +1149,7 @@ void *ldap_pvt_sasl_mutex_new(void) if ( ldap_pvt_thread_mutex_init( mutex ) == 0 ) { return mutex; } + LDAP_FREE( mutex ); #ifndef LDAP_DEBUG_R_SASL assert( 0 ); #endif /* !LDAP_DEBUG_R_SASL */ diff --git a/libraries/libldap/dnssrv.c b/libraries/libldap/dnssrv.c index 51a711ac67..915472e7be 100644 --- a/libraries/libldap/dnssrv.c +++ b/libraries/libldap/dnssrv.c @@ -361,12 +361,14 @@ int ldap_domain2hostlist( hostent_head[hostent_count].priority=priority; hostent_head[hostent_count].weight=weight; hostent_head[hostent_count].port=port; - strncpy(hostent_head[hostent_count].hostname, host, MAXHOST); + strncpy(hostent_head[hostent_count].hostname, host, MAXHOST-1); + hostent_head[hostent_count].hostname[MAXHOST-1] = '\0'; hostent_count++; } add_size:; p += size; } + if (!hostent_head) goto out; qsort(hostent_head, hostent_count, sizeof(srv_record), srv_cmp); if (!srv_seed) diff --git a/libraries/libldap/filter.c b/libraries/libldap/filter.c index 7b7bd88704..f674517017 100644 --- a/libraries/libldap/filter.c +++ b/libraries/libldap/filter.c @@ -77,7 +77,6 @@ static int ldap_is_oid ( const char *str ) dot=0; } else if ( str[i] == '.' ) { - if( dot ) return 0; if( ++dot > 1 ) return 0; } else { @@ -120,7 +119,6 @@ static int ldap_is_desc ( const char *str ) dot=0; } else if ( str[i] == '.' ) { - if( dot ) return 0; if( ++dot > 1 ) return 0; } else { @@ -938,7 +936,7 @@ ldap_put_vrFilter( BerElement *ber, const char *str_in ) int rc =0; if ( ber_printf( ber, "{" /*"}"*/ ) == -1 ) { - rc = -1; + return -1; } rc = put_vrFilter( ber, str_in ); diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 20a6c39ca0..d922d2d544 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -1438,6 +1438,7 @@ ldap_chase_referrals( LDAP *ld, id, sref, srv, &rinfo.ri_request ); if ( ber == NULL ) { + ldap_free_urllist( srv ); return -1 ; } -- GitLab