[Asterisk-code-review] func_callerid+res_agi: Fix compile errors related to -Werror=zero-len... (asterisk[16])
George Joseph
asteriskteam at digium.com
Wed Mar 10 08:57:03 CST 2021
George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15608 )
Change subject: func_callerid+res_agi: Fix compile errors related to -Werror=zero-length-bounds
......................................................................
func_callerid+res_agi: Fix compile errors related to -Werror=zero-length-bounds
Change-Id: I75152cece8a00b7523d542e5ac22796f9595692b
Signed-off-by: Jaco Kroon <jaco at uls.co.za>
---
M funcs/func_callerid.c
M res/res_agi.c
2 files changed, 76 insertions(+), 76 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c
index 0b6ab51..445ff3e 100644
--- a/funcs/func_callerid.c
+++ b/funcs/func_callerid.c
@@ -1010,11 +1010,11 @@
ast_callerid_split(args.cid, name, sizeof(name), num, sizeof(num));
- if (member.argc == 1 && !strcasecmp("all", member.argv[0])) {
+ if (member.argc == 1 && !strcasecmp("all", member.subnames[0])) {
snprintf(buf, len, "\"%s\" <%s>", name, num);
- } else if (member.argc == 1 && !strcasecmp("name", member.argv[0])) {
+ } else if (member.argc == 1 && !strcasecmp("name", member.subnames[0])) {
ast_copy_string(buf, name, len);
- } else if (member.argc == 1 && !strncasecmp("num", member.argv[0], 3)) {
+ } else if (member.argc == 1 && !strncasecmp("num", member.subnames[0], 3)) {
/* Accept num[ber] */
ast_copy_string(buf, num, len);
} else {
@@ -1024,18 +1024,18 @@
enum ID_FIELD_STATUS status;
ast_channel_lock(chan);
- if (member.argc == 1 && !strcasecmp("rdnis", member.argv[0])) {
+ if (member.argc == 1 && !strcasecmp("rdnis", member.subnames[0])) {
if (ast_channel_redirecting(chan)->from.number.valid
&& ast_channel_redirecting(chan)->from.number.str) {
ast_copy_string(buf, ast_channel_redirecting(chan)->from.number.str, len);
}
- } else if (!strcasecmp("dnid", member.argv[0])) {
+ } else if (!strcasecmp("dnid", member.subnames[0])) {
if (member.argc == 1) {
/* Setup as if user had given dnid-num instead. */
member.argc = 2;
- member.argv[1] = "num";
+ member.subnames[1] = "num";
}
- if (!strncasecmp("num", member.argv[1], 3)) {
+ if (!strncasecmp("num", member.subnames[1], 3)) {
/*
* Accept num[ber]
* dnid-num...
@@ -1045,18 +1045,18 @@
if (ast_channel_dialed(chan)->number.str) {
ast_copy_string(buf, ast_channel_dialed(chan)->number.str, len);
}
- } else if (member.argc == 3 && !strcasecmp("plan", member.argv[2])) {
+ } else if (member.argc == 3 && !strcasecmp("plan", member.subnames[2])) {
/* dnid-num-plan */
snprintf(buf, len, "%d", ast_channel_dialed(chan)->number.plan);
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
- } else if (!strncasecmp("subaddr", member.argv[1], 7)) {
+ } else if (!strncasecmp("subaddr", member.subnames[1], 7)) {
/*
* Accept subaddr[ess]
* dnid-subaddr...
*/
- status = party_subaddress_read(buf, len, member.argc - 2, member.argv + 2,
+ status = party_subaddress_read(buf, len, member.argc - 2, member.subnames + 2,
&ast_channel_dialed(chan)->subaddress);
switch (status) {
case ID_FIELD_VALID:
@@ -1069,15 +1069,15 @@
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
- } else if (member.argc == 1 && !strcasecmp("ani2", member.argv[0])) {
+ } else if (member.argc == 1 && !strcasecmp("ani2", member.subnames[0])) {
snprintf(buf, len, "%d", ast_channel_caller(chan)->ani2);
- } else if (!strcasecmp("ani", member.argv[0])) {
+ } else if (!strcasecmp("ani", member.subnames[0])) {
if (member.argc == 1) {
/* Setup as if user had given ani-num instead. */
member.argc = 2;
- member.argv[1] = "num";
+ member.subnames[1] = "num";
}
- status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
+ status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
&ast_channel_caller(chan)->ani);
switch (status) {
case ID_FIELD_VALID:
@@ -1087,8 +1087,8 @@
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
break;
}
- } else if (!strcasecmp("priv", member.argv[0])) {
- status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
+ } else if (!strcasecmp("priv", member.subnames[0])) {
+ status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
&ast_channel_caller(chan)->priv);
switch (status) {
case ID_FIELD_VALID:
@@ -1099,7 +1099,7 @@
break;
}
} else {
- status = party_id_read(buf, len, member.argc, member.argv, &ast_channel_caller(chan)->id);
+ status = party_id_read(buf, len, member.argc, member.subnames, &ast_channel_caller(chan)->id);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
@@ -1158,18 +1158,18 @@
value = ast_skip_blanks(value);
ast_channel_lock(chan);
- if (member.argc == 1 && !strcasecmp("rdnis", member.argv[0])) {
+ if (member.argc == 1 && !strcasecmp("rdnis", member.subnames[0])) {
ast_channel_redirecting(chan)->from.number.valid = 1;
ast_free(ast_channel_redirecting(chan)->from.number.str);
ast_channel_redirecting(chan)->from.number.str = ast_strdup(value);
- } else if (!strcasecmp("dnid", member.argv[0])) {
+ } else if (!strcasecmp("dnid", member.subnames[0])) {
ast_party_dialed_set_init(&dialed, ast_channel_dialed(chan));
if (member.argc == 1) {
/* Setup as if user had given dnid-num instead. */
member.argc = 2;
- member.argv[1] = "num";
+ member.subnames[1] = "num";
}
- if (!strncasecmp("num", member.argv[1], 3)) {
+ if (!strncasecmp("num", member.subnames[1], 3)) {
/*
* Accept num[ber]
* dnid-num...
@@ -1179,7 +1179,7 @@
dialed.number.str = ast_strdup(value);
ast_trim_blanks(dialed.number.str);
ast_party_dialed_set(ast_channel_dialed(chan), &dialed);
- } else if (member.argc == 3 && !strcasecmp("plan", member.argv[2])) {
+ } else if (member.argc == 3 && !strcasecmp("plan", member.subnames[2])) {
/* dnid-num-plan */
val = ast_strdupa(value);
ast_trim_blanks(val);
@@ -1193,13 +1193,13 @@
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
- } else if (!strncasecmp("subaddr", member.argv[1], 7)) {
+ } else if (!strncasecmp("subaddr", member.subnames[1], 7)) {
/*
* Accept subaddr[ess]
* dnid-subaddr...
*/
status = party_subaddress_write(&dialed.subaddress, member.argc - 2,
- member.argv + 2, value);
+ member.subnames + 2, value);
switch (status) {
case ID_FIELD_VALID:
ast_party_dialed_set(ast_channel_dialed(chan), &dialed);
@@ -1214,7 +1214,7 @@
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
ast_party_dialed_free(&dialed);
- } else if (member.argc == 1 && !strcasecmp("ani2", member.argv[0])) {
+ } else if (member.argc == 1 && !strcasecmp("ani2", member.subnames[0])) {
val = ast_strdupa(value);
ast_trim_blanks(val);
@@ -1223,14 +1223,14 @@
} else {
ast_log(LOG_ERROR, "Unknown callerid ani2 '%s', value unchanged\n", val);
}
- } else if (!strcasecmp("ani", member.argv[0])) {
+ } else if (!strcasecmp("ani", member.subnames[0])) {
ast_party_caller_set_init(&caller, ast_channel_caller(chan));
if (member.argc == 1) {
/* Setup as if user had given ani-num instead. */
member.argc = 2;
- member.argv[1] = "num";
+ member.subnames[1] = "num";
}
- status = party_id_write(&caller.ani, member.argc - 1, member.argv + 1, value);
+ status = party_id_write(&caller.ani, member.argc - 1, member.subnames + 1, value);
switch (status) {
case ID_FIELD_VALID:
ast_party_caller_set(ast_channel_caller(chan), &caller, NULL);
@@ -1242,9 +1242,9 @@
break;
}
ast_party_caller_free(&caller);
- } else if (!strcasecmp("priv", member.argv[0])) {
+ } else if (!strcasecmp("priv", member.subnames[0])) {
ast_party_caller_set_init(&caller, ast_channel_caller(chan));
- status = party_id_write(&caller.priv, member.argc - 1, member.argv + 1, value);
+ status = party_id_write(&caller.priv, member.argc - 1, member.subnames + 1, value);
switch (status) {
case ID_FIELD_VALID:
ast_party_caller_set(ast_channel_caller(chan), &caller, NULL);
@@ -1258,7 +1258,7 @@
ast_party_caller_free(&caller);
} else {
ast_party_caller_set_init(&caller, ast_channel_caller(chan));
- status = party_id_write(&caller.id, member.argc, member.argv, value);
+ status = party_id_write(&caller.id, member.argc, member.subnames, value);
switch (status) {
case ID_FIELD_VALID:
ast_channel_set_caller_event(chan, &caller, NULL);
@@ -1311,10 +1311,10 @@
ast_channel_lock(chan);
- if (member.argc == 1 && !strcasecmp("source", member.argv[0])) {
+ if (member.argc == 1 && !strcasecmp("source", member.subnames[0])) {
ast_copy_string(buf, ast_connected_line_source_name(ast_channel_connected(chan)->source), len);
- } else if (!strcasecmp("priv", member.argv[0])) {
- status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
+ } else if (!strcasecmp("priv", member.subnames[0])) {
+ status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
&ast_channel_connected(chan)->priv);
switch (status) {
case ID_FIELD_VALID:
@@ -1325,7 +1325,7 @@
break;
}
} else {
- status = party_id_read(buf, len, member.argc, member.argv, &ast_channel_connected(chan)->id);
+ status = party_id_read(buf, len, member.argc, member.subnames, &ast_channel_connected(chan)->id);
switch (status) {
case ID_FIELD_VALID:
case ID_FIELD_INVALID:
@@ -1400,7 +1400,7 @@
value = ast_skip_blanks(value);
- if (member.argc == 1 && !strcasecmp("source", member.argv[0])) {
+ if (member.argc == 1 && !strcasecmp("source", member.subnames[0])) {
int source;
val = ast_strdupa(value);
@@ -1418,8 +1418,8 @@
connected.source = source;
set_it(chan, &connected, NULL);
}
- } else if (!strcasecmp("priv", member.argv[0])) {
- status = party_id_write(&connected.priv, member.argc - 1, member.argv + 1, value);
+ } else if (!strcasecmp("priv", member.subnames[0])) {
+ status = party_id_write(&connected.priv, member.argc - 1, member.subnames + 1, value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &connected, NULL);
@@ -1432,7 +1432,7 @@
}
ast_party_connected_line_free(&connected);
} else {
- status = party_id_write(&connected.id, member.argc, member.argv, value);
+ status = party_id_write(&connected.id, member.argc, member.subnames, value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &connected, NULL);
@@ -1486,12 +1486,12 @@
ast_channel_lock(chan);
ast_redirecting = ast_channel_redirecting(chan);
- if (!strcasecmp("orig", member.argv[0])) {
- if (member.argc == 2 && !strcasecmp("reason", member.argv[1])) {
+ if (!strcasecmp("orig", member.subnames[0])) {
+ if (member.argc == 2 && !strcasecmp("reason", member.subnames[1])) {
ast_copy_string(buf,
ast_redirecting_reason_name(&ast_redirecting->orig_reason), len);
} else {
- status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
+ status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
&ast_redirecting->orig);
switch (status) {
case ID_FIELD_VALID:
@@ -1502,8 +1502,8 @@
break;
}
}
- } else if (!strcasecmp("from", member.argv[0])) {
- status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
+ } else if (!strcasecmp("from", member.subnames[0])) {
+ status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
&ast_redirecting->from);
switch (status) {
case ID_FIELD_VALID:
@@ -1513,8 +1513,8 @@
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
- } else if (!strcasecmp("to", member.argv[0])) {
- status = party_id_read(buf, len, member.argc - 1, member.argv + 1,
+ } else if (!strcasecmp("to", member.subnames[0])) {
+ status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
&ast_redirecting->to);
switch (status) {
case ID_FIELD_VALID:
@@ -1524,7 +1524,7 @@
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
- } else if (member.argc == 1 && !strncasecmp("pres", member.argv[0], 4)) {
+ } else if (member.argc == 1 && !strncasecmp("pres", member.subnames[0], 4)) {
/*
* Accept pres[entation]
* This is the combined from name/number presentation.
@@ -1532,13 +1532,13 @@
ast_copy_string(buf,
ast_named_caller_presentation(
ast_party_id_presentation(&ast_redirecting->from)), len);
- } else if (member.argc == 1 && !strcasecmp("reason", member.argv[0])) {
+ } else if (member.argc == 1 && !strcasecmp("reason", member.subnames[0])) {
ast_copy_string(buf, ast_redirecting_reason_name(&ast_redirecting->reason), len);
- } else if (member.argc == 1 && !strcasecmp("count", member.argv[0])) {
+ } else if (member.argc == 1 && !strcasecmp("count", member.subnames[0])) {
snprintf(buf, len, "%d", ast_redirecting->count);
- } else if (1 < member.argc && !strcasecmp("priv", member.argv[0])) {
- if (!strcasecmp("orig", member.argv[1])) {
- status = party_id_read(buf, len, member.argc - 2, member.argv + 2,
+ } else if (1 < member.argc && !strcasecmp("priv", member.subnames[0])) {
+ if (!strcasecmp("orig", member.subnames[1])) {
+ status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
&ast_redirecting->priv_orig);
switch (status) {
case ID_FIELD_VALID:
@@ -1548,8 +1548,8 @@
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
- } else if (!strcasecmp("from", member.argv[1])) {
- status = party_id_read(buf, len, member.argc - 2, member.argv + 2,
+ } else if (!strcasecmp("from", member.subnames[1])) {
+ status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
&ast_redirecting->priv_from);
switch (status) {
case ID_FIELD_VALID:
@@ -1559,8 +1559,8 @@
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
- } else if (!strcasecmp("to", member.argv[1])) {
- status = party_id_read(buf, len, member.argc - 2, member.argv + 2,
+ } else if (!strcasecmp("to", member.subnames[1])) {
+ status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
&ast_redirecting->priv_to);
switch (status) {
case ID_FIELD_VALID:
@@ -1641,8 +1641,8 @@
value = ast_skip_blanks(value);
- if (!strcasecmp("orig", member.argv[0])) {
- if (member.argc == 2 && !strcasecmp("reason", member.argv[1])) {
+ if (!strcasecmp("orig", member.subnames[0])) {
+ if (member.argc == 2 && !strcasecmp("reason", member.subnames[1])) {
int reason;
val = ast_strdupa(value);
@@ -1668,7 +1668,7 @@
set_it(chan, &redirecting, NULL);
}
} else {
- status = party_id_write(&redirecting.orig, member.argc - 1, member.argv + 1,
+ status = party_id_write(&redirecting.orig, member.argc - 1, member.subnames + 1,
value);
switch (status) {
case ID_FIELD_VALID:
@@ -1682,8 +1682,8 @@
}
ast_party_redirecting_free(&redirecting);
}
- } else if (!strcasecmp("from", member.argv[0])) {
- status = party_id_write(&redirecting.from, member.argc - 1, member.argv + 1,
+ } else if (!strcasecmp("from", member.subnames[0])) {
+ status = party_id_write(&redirecting.from, member.argc - 1, member.subnames + 1,
value);
switch (status) {
case ID_FIELD_VALID:
@@ -1696,8 +1696,8 @@
break;
}
ast_party_redirecting_free(&redirecting);
- } else if (!strcasecmp("to", member.argv[0])) {
- status = party_id_write(&redirecting.to, member.argc - 1, member.argv + 1, value);
+ } else if (!strcasecmp("to", member.subnames[0])) {
+ status = party_id_write(&redirecting.to, member.argc - 1, member.subnames + 1, value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &redirecting, NULL);
@@ -1709,7 +1709,7 @@
break;
}
ast_party_redirecting_free(&redirecting);
- } else if (member.argc == 1 && !strncasecmp("pres", member.argv[0], 4)) {
+ } else if (member.argc == 1 && !strncasecmp("pres", member.subnames[0], 4)) {
int pres;
val = ast_strdupa(value);
@@ -1731,7 +1731,7 @@
redirecting.to.number.presentation = pres;
set_it(chan, &redirecting, NULL);
}
- } else if (member.argc == 1 && !strcasecmp("reason", member.argv[0])) {
+ } else if (member.argc == 1 && !strcasecmp("reason", member.subnames[0])) {
int reason;
val = ast_strdupa(value);
@@ -1756,7 +1756,7 @@
redirecting.reason.str = "";
set_it(chan, &redirecting, NULL);
}
- } else if (member.argc == 1 && !strcasecmp("count", member.argv[0])) {
+ } else if (member.argc == 1 && !strcasecmp("count", member.subnames[0])) {
val = ast_strdupa(value);
ast_trim_blanks(val);
@@ -1766,9 +1766,9 @@
} else {
ast_log(LOG_ERROR, "Unknown redirecting count '%s', value unchanged\n", val);
}
- } else if (1 < member.argc && !strcasecmp("priv", member.argv[0])) {
- if (!strcasecmp("orig", member.argv[1])) {
- status = party_id_write(&redirecting.priv_orig, member.argc - 2, member.argv + 2,
+ } else if (1 < member.argc && !strcasecmp("priv", member.subnames[0])) {
+ if (!strcasecmp("orig", member.subnames[1])) {
+ status = party_id_write(&redirecting.priv_orig, member.argc - 2, member.subnames + 2,
value);
switch (status) {
case ID_FIELD_VALID:
@@ -1781,8 +1781,8 @@
break;
}
ast_party_redirecting_free(&redirecting);
- } else if (!strcasecmp("from", member.argv[1])) {
- status = party_id_write(&redirecting.priv_from, member.argc - 2, member.argv + 2,
+ } else if (!strcasecmp("from", member.subnames[1])) {
+ status = party_id_write(&redirecting.priv_from, member.argc - 2, member.subnames + 2,
value);
switch (status) {
case ID_FIELD_VALID:
@@ -1795,8 +1795,8 @@
break;
}
ast_party_redirecting_free(&redirecting);
- } else if (!strcasecmp("to", member.argv[1])) {
- status = party_id_write(&redirecting.priv_to, member.argc - 2, member.argv + 2, value);
+ } else if (!strcasecmp("to", member.subnames[1])) {
+ status = party_id_write(&redirecting.priv_to, member.argc - 2, member.subnames + 2, value);
switch (status) {
case ID_FIELD_VALID:
set_it(chan, &redirecting, NULL);
diff --git a/res/res_agi.c b/res/res_agi.c
index 6f8815d..5763a5b 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -4510,7 +4510,7 @@
memset(&agi, 0, sizeof(agi));
buf = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, buf);
- args.argv[args.argc] = NULL;
+ args.arg[args.argc] = NULL;
#if 0
/* Answer if need be */
if (chan->_state != AST_STATE_UP) {
@@ -4518,7 +4518,7 @@
return -1;
}
#endif
- res = launch_script(chan, args.argv[0], args.argc, args.argv, fds, enhanced ? &efd : NULL, &pid);
+ res = launch_script(chan, args.arg[0], args.argc, args.arg, fds, enhanced ? &efd : NULL, &pid);
/* Async AGI do not require run_agi(), so just proceed if normal AGI
or Fast AGI are setup with success. */
if (res == AGI_RESULT_SUCCESS || res == AGI_RESULT_SUCCESS_FAST) {
@@ -4527,7 +4527,7 @@
agi.ctrl = fds[0];
agi.audio = efd;
agi.fast = (res == AGI_RESULT_SUCCESS_FAST) ? 1 : 0;
- res = run_agi(chan, args.argv[0], &agi, pid, &status, dead, args.argc, args.argv);
+ res = run_agi(chan, args.arg[0], &agi, pid, &status, dead, args.argc, args.arg);
/* If the fork'd process returns non-zero, set AGISTATUS to FAILURE */
if ((res == AGI_RESULT_SUCCESS || res == AGI_RESULT_SUCCESS_FAST) && status)
res = AGI_RESULT_FAILURE;
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15608
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I75152cece8a00b7523d542e5ac22796f9595692b
Gerrit-Change-Number: 15608
Gerrit-PatchSet: 2
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jaco Kroon <jaco at uls.co.za>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210310/d6b4954b/attachment-0001.html>
More information about the asterisk-code-review
mailing list