]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Check the return value of ldap_sync init functions
authorNick Porter <nick@portercomputing.co.uk>
Thu, 17 Nov 2022 19:42:43 +0000 (19:42 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 18 Nov 2022 18:09:56 +0000 (18:09 +0000)
src/listen/ldap_sync/proto_ldap_sync_ldap.c

index 7a4e8d6fccd2a7d923e43d64111cc1064dc83b94..811ae27f4f86d7a1fb8440e2635fa9118356f1a4 100644 (file)
@@ -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