]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_if: Fix format truncation errors.
authorNaveen Albert <asterisk@phreaknet.org>
Mon, 12 Dec 2022 15:16:17 +0000 (15:16 +0000)
committerN A <asterisk@phreaknet.org>
Tue, 13 Dec 2022 13:18:03 +0000 (08:18 -0500)
Fixes format truncation warnings in gcc 12.2.1.

ASTERISK-30349 #close

Change-Id: I42be4edf0284358b906e765d1966b6b9d66e1d3c

apps/app_if.c

index b1ff0ada83f6648395df6f1a8640e98441e76461..bc04ffd71bb570c53cb3f1e744b8285f80d697b6 100644 (file)
@@ -234,7 +234,8 @@ static int if_helper(struct ast_channel *chan, const char *data, int end)
        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 @@ static int if_helper(struct ast_channel *chan, const char *data, int end)
                }
        }
 
-       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);