From: Nick Porter Date: Thu, 17 Nov 2022 19:42:43 +0000 (+0000) Subject: Check the return value of ldap_sync init functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9c93297f6c1775fe31afe551fbc6d4d30258602;p=thirdparty%2Ffreeradius-server.git Check the return value of ldap_sync init functions --- diff --git a/src/listen/ldap_sync/proto_ldap_sync_ldap.c b/src/listen/ldap_sync/proto_ldap_sync_ldap.c index 7a4e8d6fccd..811ae27f4f8 100644 --- a/src/listen/ldap_sync/proto_ldap_sync_ldap.c +++ b/src/listen/ldap_sync/proto_ldap_sync_ldap.c @@ -755,11 +755,7 @@ static ssize_t proto_ldap_child_mod_write(fr_listen_t *li, void *packet_ctx, UNU fr_pair_list_init(&tmp); ret = fr_internal_decode_list_dbuff(local, &tmp, fr_dict_root(dict_ldap_sync), &dbuff, NULL); - if (ret < 0) { - fr_pair_list_free(&tmp); - talloc_free(local); - return ret; - } + if (ret < 0) goto finish; /* * There should always be a packet ID and code @@ -789,7 +785,10 @@ static ssize_t proto_ldap_child_mod_write(fr_listen_t *li, void *packet_ctx, UNU vp = fr_pair_find_by_da_nested(&tmp, NULL, attr_ldap_sync_cookie); if (vp) cookie = talloc_memdup(inst, vp->vp_octets, vp->vp_length); - inst->parent->sync_config[packet_id]->init(thread->conn->h, packet_id, inst->parent, cookie); + if (inst->parent->sync_config[packet_id]->init(thread->conn->h, packet_id, inst->parent, cookie) < 0) { + ret = -1; + goto finish; + } } break; @@ -808,7 +807,11 @@ static ssize_t proto_ldap_child_mod_write(fr_listen_t *li, void *packet_ctx, UNU sync_config = sync_packet_ctx->sync->config; DEBUG3("Restarting sync with base %s", sync_config->base_dn); talloc_free(sync_packet_ctx->sync); - inst->parent->sync_config[packet_id]->init(thread->conn->h, packet_id, inst->parent, sync_packet_ctx->cookie); + if (inst->parent->sync_config[packet_id]->init(thread->conn->h, packet_id, inst->parent, + sync_packet_ctx->cookie) < 0) { + ret = -1; + goto finish; + } } break; @@ -865,10 +868,11 @@ static ssize_t proto_ldap_child_mod_write(fr_listen_t *li, void *packet_ctx, UNU (sync->changes_since_cookie >= ldap_sync->cookie_changes)) ldap_sync_cookie_send(pc); } +finish: fr_pair_list_free(&tmp); talloc_free(local); - return buffer_len; + return ret; } /** Callback for socket errors when running initial root query