1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

librpc/rpc: apply some code cleanup and error checks to dcesrv_mgmt.c

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Stefan Metzmacher 2023-08-09 12:42:43 +02:00 committed by Andrew Bartlett
parent a38f58ac85
commit 6cb12d3955

View File

@ -49,17 +49,27 @@ static WERROR dcesrv_mgmt_inq_if_ids(struct dcesrv_call_state *dce_call, TALLOC_
struct mgmt_inq_if_ids *r)
{
const struct dcesrv_endpoint *ep = dce_call->conn->endpoint;
struct dcesrv_if_list *l;
struct rpc_if_id_vector_t *vector;
struct dcesrv_if_list *l = NULL;
struct rpc_if_id_vector_t *vector = NULL;
vector = talloc(mem_ctx, struct rpc_if_id_vector_t);
if (vector == NULL) {
return WERR_NOT_ENOUGH_MEMORY;
}
vector = *r->out.if_id_vector = talloc(mem_ctx, struct rpc_if_id_vector_t);
vector->count = 0;
vector->if_id = NULL;
for (l = ep->interface_list; l; l = l->next) {
vector->count++;
vector->if_id = talloc_realloc(mem_ctx, vector->if_id, struct ndr_syntax_id_p, vector->count);
vector->if_id = talloc_realloc(vector, vector->if_id, struct ndr_syntax_id_p, vector->count);
if (vector->if_id == NULL) {
return WERR_NOT_ENOUGH_MEMORY;
}
vector->if_id[vector->count-1].id = &l->iface->syntax_id;
}
*r->out.if_id_vector = vector;
return WERR_OK;
}
@ -73,8 +83,13 @@ static WERROR dcesrv_mgmt_inq_stats(struct dcesrv_call_state *dce_call, TALLOC_C
if (r->in.max_count != MGMT_STATS_ARRAY_MAX_SIZE)
return WERR_NOT_SUPPORTED;
r->out.statistics->statistics = talloc_zero_array(mem_ctx,
uint32_t,
r->in.max_count);
if (r->out.statistics->statistics == NULL) {
return WERR_NOT_ENOUGH_MEMORY;
}
r->out.statistics->count = r->in.max_count;
r->out.statistics->statistics = talloc_array(mem_ctx, uint32_t, r->in.max_count);
/* FIXME */
r->out.statistics->statistics[MGMT_STATS_CALLS_IN] = 0;
r->out.statistics->statistics[MGMT_STATS_CALLS_OUT] = 0;