From 45be1f5212a20f0907120eb6e164cbf369f91810 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 17 Apr 2026 09:25:09 -0400 Subject: [PATCH] MT#55283 honour errors returns from parse Change-Id: Iabc7477c38e3e7a8c533ea36fa64bf5ef87431d3 --- daemon/call_flags.c | 4 ++-- daemon/call_interfaces.c | 32 ++++++++++++++++++++------------ include/call_flags.h | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/daemon/call_flags.c b/daemon/call_flags.c index 1e5c7694c..41e971f3e 100644 --- a/daemon/call_flags.c +++ b/daemon/call_flags.c @@ -2094,7 +2094,7 @@ const char *call_ng_main_flags(const ng_parser_t *parser, str *key, parser_arg v return NULL; } -void call_ng_process_flags(sdp_ng_flags *out, ng_command_ctx_t *ctx) { +const char *call_ng_process_flags(sdp_ng_flags *out, ng_command_ctx_t *ctx) { const ng_parser_t *parser = ctx->parser_ctx.parser; call_ng_flags_init(out, ctx->opmode); ctx->flags = out; @@ -2106,7 +2106,7 @@ void call_ng_process_flags(sdp_ng_flags *out, ng_command_ctx_t *ctx) { if (ctx->opmode != OP_OTHER && rtpe_default_signalling_templates[ctx->opmode].len) parse_rtpp_flags(&rtpe_default_signalling_templates[ctx->opmode], out); - parser->dict_iter(parser, ctx->req, call_ng_main_flags, out); + return parser->dict_iter(parser, ctx->req, call_ng_main_flags, out); } diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 277e28a92..17281ffe4 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -32,6 +32,14 @@ #include "call_flags.h" +#define call_ng_process_flags_RETURN(a, b) \ + do { \ + const char *__err = call_ng_process_flags(a, b); \ + if (__err) \ + return __err; \ + } while (0) + + static pcre2_code *info_re; static pcre2_code *streams_re; @@ -557,7 +565,7 @@ static const char *call_offer_answer_ng(ng_command_ctx_t *ctx, const char *addr) const ng_parser_t *parser = ctx->parser_ctx.parser; g_auto(str) sdp_out = STR_NULL; - call_ng_process_flags(&flags, ctx); + call_ng_process_flags_RETURN(&flags, ctx); if ((ret = call_ng_basic_checks(&flags)) > 0) return _ng_basic_errors[ret]; @@ -732,7 +740,7 @@ const char *call_delete_ng(ng_command_ctx_t *ctx) { parser_arg output = ctx->resp; const ng_parser_t *parser = ctx->parser_ctx.parser; - call_ng_process_flags(&rtpp_flags, ctx); + call_ng_process_flags_RETURN(&rtpp_flags, ctx); if (!rtpp_flags.call_id.len) return "No call-id in message"; @@ -1245,7 +1253,7 @@ static const char *call_recording_common_ng(ng_command_ctx_t *ctx, g_auto(sdp_ng_flags) flags; g_autoptr(call_t) call = NULL; - call_ng_process_flags(&flags, ctx); + call_ng_process_flags_RETURN(&flags, ctx); if (!flags.call_id.len) return "No call-id in message"; @@ -1372,7 +1380,7 @@ static const char *media_block_match(call_t **call, struct call_monologue **mono *call = NULL; *monologue = NULL; - call_ng_process_flags(flags, ctx); + call_ng_process_flags_RETURN(flags, ctx); if (!flags->call_id.s) return "No call-id in message"; @@ -1400,7 +1408,7 @@ static const char *media_block_match(call_t **call, struct call_monologue **mono static const char *medias_match(call_q *calls, medias_q *medias, sdp_ng_flags *flags, ng_command_ctx_t *ctx) { - call_ng_process_flags(flags, ctx); + call_ng_process_flags_RETURN(flags, ctx); if (!flags->call_id.s) return "No call-id in message"; @@ -2071,7 +2079,7 @@ const char *call_publish_ng(ng_command_ctx_t *ctx, const char *addr) { char rand_call_id[65]; char rand_from_tag[65]; - call_ng_process_flags(&flags, ctx); + call_ng_process_flags_RETURN(&flags, ctx); if (!flags.sdp.len) return "No SDP body in message"; @@ -2254,7 +2262,7 @@ const char *call_subscribe_answer_ng(ng_command_ctx_t *ctx) { g_auto(sdp_streams_q) streams = TYPED_GQUEUE_INIT; g_autoptr(call_t) call = NULL; - call_ng_process_flags(&flags, ctx); + call_ng_process_flags_RETURN(&flags, ctx); if (!flags.call_id.s) return "No call-id in message"; @@ -2295,7 +2303,7 @@ const char *call_unsubscribe_ng(ng_command_ctx_t *ctx) { g_auto(sdp_ng_flags) flags; g_autoptr(call_t) call = NULL; - call_ng_process_flags(&flags, ctx); + call_ng_process_flags_RETURN(&flags, ctx); if (!flags.call_id.s) return "No call-id in message"; @@ -2331,7 +2339,7 @@ const char *call_unsubscribe_ng(ng_command_ctx_t *ctx) { static const char *call_inject_ng(ng_command_ctx_t *ctx, bool start) { g_auto(sdp_ng_flags) flags; - call_ng_process_flags(&flags, ctx); + call_ng_process_flags_RETURN(&flags, ctx); if (!flags.call_id.s) return "No call-id in message"; @@ -2454,7 +2462,7 @@ const char *call_transform_ng(ng_command_ctx_t *ctx) { * } */ - call_ng_process_flags(&flags, ctx); + call_ng_process_flags_RETURN(&flags, ctx); if (flags.instance.len && !str_cmp_str(&rtpe_instance_id, &flags.instance)) return "Transform loop detected"; @@ -2502,7 +2510,7 @@ const char *call_create_ng(ng_command_ctx_t *ctx) { char rand_from_tag[65]; g_auto(str) sdp = STR_NULL; - call_ng_process_flags(&flags, ctx); + call_ng_process_flags_RETURN(&flags, ctx); if (!flags.call_id.len) flags.call_id = STR_LEN(rand_hex_str(rand_call_id, 32), 64); @@ -2536,7 +2544,7 @@ const char *call_create_answer_ng(ng_command_ctx_t *ctx) { g_auto(sdp_sessions_q) parsed = TYPED_GQUEUE_INIT; g_auto(sdp_streams_q) streams = TYPED_GQUEUE_INIT; - call_ng_process_flags(&flags, ctx); + call_ng_process_flags_RETURN(&flags, ctx); enum basic_errors ret; if ((ret = call_ng_basic_checks(&flags)) > 0) diff --git a/include/call_flags.h b/include/call_flags.h index b0e3518b7..29c9d0c21 100644 --- a/include/call_flags.h +++ b/include/call_flags.h @@ -327,7 +327,7 @@ const char *call_ng_flags_flags(str *s, unsigned int, helper_arg arg); const char *call_ng_main_flags(const ng_parser_t *, str *key, parser_arg value, helper_arg); const char *call_ng_codec_flags(const ng_parser_t *, str *key, parser_arg value, helper_arg); -void call_ng_process_flags(sdp_ng_flags *out, ng_command_ctx_t *ctx); +const char *call_ng_process_flags(sdp_ng_flags *out, ng_command_ctx_t *ctx); INLINE struct sdp_manipulations *sdp_manipulations_get_by_id(struct sdp_manipulations * const array[__MT_MAX],