[Asterisk-code-review] app_if: Fix format truncation errors. (asterisk[20])

Joshua Colp asteriskteam at digium.com
Tue Dec 13 09:28:26 CST 2022


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19722 )

Change subject: app_if: Fix format truncation errors.
......................................................................

app_if: Fix format truncation errors.

Fixes format truncation warnings in gcc 12.2.1.

ASTERISK-30349 #close

Change-Id: I42be4edf0284358b906e765d1966b6b9d66e1d3c
---
M apps/app_if.c
1 file changed, 17 insertions(+), 3 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Joshua Colp: Approved for Submit




diff --git a/apps/app_if.c b/apps/app_if.c
index b1ff0ad..bc04ffd 100644
--- a/apps/app_if.c
+++ b/apps/app_if.c
@@ -234,7 +234,8 @@
 	const char *if_pri = NULL;
 	char *my_name = NULL;
 	const char *label = NULL;
-	char varname[VAR_SIZE], end_varname[VAR_SIZE + 4];
+	char varname[VAR_SIZE + 3]; /* + IF_ */
+	char end_varname[sizeof(varname) + 4]; /* + END_ + sizeof(varname) */
 	const char *prefix = "IF";
 	size_t size = 0;
 	int used_index_i = -1, x = 0;
@@ -252,8 +253,8 @@
 		}
 	}
 
-	snprintf(used_index, VAR_SIZE, "%d", used_index_i);
-	snprintf(new_index, VAR_SIZE, "%d", used_index_i + 1);
+	snprintf(used_index, sizeof(used_index), "%d", used_index_i);
+	snprintf(new_index, sizeof(new_index), "%d", used_index_i + 1);
 
 	size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
 	my_name = ast_alloca(size);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19722
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 20
Gerrit-Change-Id: I42be4edf0284358b906e765d1966b6b9d66e1d3c
Gerrit-Change-Number: 19722
Gerrit-PatchSet: 2
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
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/20221213/348f386a/attachment.html>


More information about the asterisk-code-review mailing list