[Asterisk-code-review] func_callerid+res_agi: Fix compile errors related to -Werror=zero-len... (asterisk[master])
George Joseph
asteriskteam at digium.com
Wed Mar 10 08:57:29 CST 2021
George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15496 )
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 033366a..64aeffc 100644
--- a/funcs/func_callerid.c
+++ b/funcs/func_callerid.c
@@ -962,11 +962,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 {
@@ -976,18 +976,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...
@@ -997,18 +997,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:
@@ -1021,15 +1021,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:
@@ -1039,8 +1039,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:
@@ -1051,7 +1051,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:
@@ -1110,18 +1110,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...
@@ -1131,7 +1131,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);
@@ -1145,13 +1145,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);
@@ -1166,7 +1166,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);
@@ -1175,14 +1175,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);
@@ -1194,9 +1194,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);
@@ -1210,7 +1210,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);
@@ -1263,10 +1263,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:
@@ -1277,7 +1277,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:
@@ -1352,7 +1352,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);
@@ -1370,8 +1370,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);
@@ -1384,7 +1384,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);
@@ -1438,12 +1438,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:
@@ -1454,8 +1454,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:
@@ -1465,8 +1465,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:
@@ -1476,7 +1476,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.
@@ -1484,13 +1484,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:
@@ -1500,8 +1500,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:
@@ -1511,8 +1511,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:
@@ -1593,8 +1593,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);
@@ -1620,7 +1620,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:
@@ -1634,8 +1634,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:
@@ -1648,8 +1648,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);
@@ -1661,7 +1661,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);
@@ -1683,7 +1683,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);
@@ -1708,7 +1708,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);
@@ -1718,9 +1718,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:
@@ -1733,8 +1733,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:
@@ -1747,8 +1747,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 77ba226..b10e4ab 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/+/15496
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I75152cece8a00b7523d542e5ac22796f9595692b
Gerrit-Change-Number: 15496
Gerrit-PatchSet: 2
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-CC: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210310/e4f40f1e/attachment-0001.html>
More information about the asterisk-code-review
mailing list