From 29cc141cab87c02ce470e99af4b68739c351e45b Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Mon, 14 Aug 2017 10:41:29 +0500 Subject: [PATCH 1/2] resolve several issues found by cppcheck: [servers/slapd/slapi/slapi_overlay.c:48] -> [servers/slapd/slapi/slapi_overlay.c:53]: (warning) Either the condition '(pb)!=NULL' is redundant or there is possible null pointer dereference: pb. [servers/slapd/slapi/slapi_overlay.c:49] -> [servers/slapd/slapi/slapi_overlay.c:53]: (warning) Either the condition '(pb)!=NULL' is redundant or there is possible null pointer dereference: pb. [servers/slapd/slapi/slapi_overlay.c:50] -> [servers/slapd/slapi/slapi_overlay.c:53]: (warning) Either the condition '(pb)!=NULL' is redundant or there is possible null pointer dereference: pb. [servers/slapd/slapi/slapi_overlay.c:51] -> [servers/slapd/slapi/slapi_overlay.c:53]: (warning) Either the condition '(pb)!=NULL' is redundant or there is possible null pointer dereference: pb. [libraries/libreldap/ntlm.c:104] -> [libraries/libreldap/ntlm.c:107]: (warning) Either the condition 'ld==NULL' is redundant or there is possible null pointer dereference: ld. --- libraries/libreldap/ntlm.c | 8 ++++---- servers/slapd/slapi/slapi_overlay.c | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libraries/libreldap/ntlm.c b/libraries/libreldap/ntlm.c index 5e913ed015..33ccb53d90 100644 --- a/libraries/libreldap/ntlm.c +++ b/libraries/libreldap/ntlm.c @@ -100,14 +100,14 @@ ldap_parse_ntlm_bind_result( Debug( LDAP_DEBUG_TRACE, "ldap_parse_ntlm_bind_result\n" ); - assert( ld != NULL ); - assert( LDAP_VALID( ld ) ); - assert( res != NULL ); - if ( ld == NULL || res == NULL ) { return LDAP_PARAM_ERROR; } + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( res != NULL ); + if( res->lm_msgtype != LDAP_RES_BIND ) { ld->ld_errno = LDAP_PARAM_ERROR; return ld->ld_errno; diff --git a/servers/slapd/slapi/slapi_overlay.c b/servers/slapd/slapi/slapi_overlay.c index 97f99035e3..4355956e8a 100644 --- a/servers/slapd/slapi/slapi_overlay.c +++ b/servers/slapd/slapi/slapi_overlay.c @@ -45,13 +45,12 @@ slapi_over_pblock_new( Operation *op, SlapReply *rs ) Slapi_PBlock *pb; pb = slapi_pblock_new(); + PBLOCK_ASSERT_OP( pb, op->o_tag ); pb->pb_op = op; pb->pb_conn = op->o_conn; pb->pb_rs = rs; pb->pb_intop = 0; - PBLOCK_ASSERT_OP( pb, op->o_tag ); - return pb; } From d8ab7146c91254b30cc30961311365cdf60bfa52 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Mon, 14 Aug 2017 10:47:24 +0500 Subject: [PATCH 2/2] resolve cppcheck warnings: [libraries/libreldap/sortctrl.c:282] -> [libraries/libreldap/sortctrl.c:284]: (warning) Either the condition 'ld==NULL' is redundant or there is possible null pointer dereference: ld. [libraries/libreldap/sortctrl.c:399] -> [libraries/libreldap/sortctrl.c:401]: (warning) Either the condition 'ld==NULL' is redundant or there is possible null pointer dereference: ld. [libraries/libreldap/sortctrl.c:482] -> [libraries/libreldap/sortctrl.c:484]: (warning) Either the condition 'ld==NULL' is redundant or there is possible null pointer dereference: ld. --- libraries/libreldap/sortctrl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/libreldap/sortctrl.c b/libraries/libreldap/sortctrl.c index 85220b3e97..bfc24a9d10 100644 --- a/libraries/libreldap/sortctrl.c +++ b/libraries/libreldap/sortctrl.c @@ -279,9 +279,11 @@ ldap_create_sort_control_value( ber_tag_t tag; assert( ld != NULL ); - assert( LDAP_VALID( ld ) ); if ( ld == NULL ) return LDAP_PARAM_ERROR; + + assert( LDAP_VALID( ld ) ); + if ( keyList == NULL || value == NULL ) { ld->ld_errno = LDAP_PARAM_ERROR; return LDAP_PARAM_ERROR; @@ -396,12 +398,13 @@ ldap_create_sort_control( struct berval value; assert( ld != NULL ); - assert( LDAP_VALID( ld ) ); if ( ld == NULL ) { return LDAP_PARAM_ERROR; } + assert( LDAP_VALID( ld ) ); + if ( ctrlp == NULL ) { ld->ld_errno = LDAP_PARAM_ERROR; return ld->ld_errno; @@ -479,12 +482,13 @@ ldap_parse_sortresponse_control( ber_len_t berLen; assert( ld != NULL ); - assert( LDAP_VALID( ld ) ); if (ld == NULL) { return LDAP_PARAM_ERROR; } + assert( LDAP_VALID( ld ) ); + if (ctrl == NULL) { ld->ld_errno = LDAP_PARAM_ERROR; return(ld->ld_errno);