Module: kamailio
Branch: master
Commit: e614575d53f5e3b7d3a4796a445728f862e60916
URL:
https://github.com/kamailio/kamailio/commit/e614575d53f5e3b7d3a4796a445728f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-12-11T09:53:48+01:00
sca: check return for snprintf()
---
Modified: src/modules/sca/sca_call_info.c
---
Diff:
https://github.com/kamailio/kamailio/commit/e614575d53f5e3b7d3a4796a445728f…
Patch:
https://github.com/kamailio/kamailio/commit/e614575d53f5e3b7d3a4796a445728f…
---
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
index a1af143c017..2694239cb9f 100644
--- a/src/modules/sca/sca_call_info.c
+++ b/src/modules/sca/sca_call_info.c
@@ -112,6 +112,7 @@ static int sca_call_info_header_append_appearances(
str state_str;
int slot_idx;
int len = -1;
+ int l1 = -1;
int usedlen = -1;
slot_idx =
@@ -153,9 +154,14 @@ static int sca_call_info_header_append_appearances(
sca_appearance_state_to_str(app->state, &state_str);
// state_str.s is a nul-terminated string literal
- len += snprintf(hdrbuf + len, maxlen - len,
+ l1 = snprintf(hdrbuf + len, maxlen - len,
">;appearance-index=%d;appearance-state=%s", app->index,
state_str.s);
+ if(l1 < 0 || l1 >= maxlen - len) {
+ LM_ERR("failed to print the header\n");
+ return -1;
+ }
+ len += l1;
if(!SCA_STR_EMPTY(&app->uri)) {
hdrbuf[len] = ';';