]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
func_callerid: Always format ANI2 as two digits.
authorNaveen Albert <asterisk@phreaknet.org>
Sat, 26 Apr 2025 12:38:45 +0000 (08:38 -0400)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 29 Apr 2025 12:13:48 +0000 (12:13 +0000)
ANI II is always supposed to be formatted as two digits,
so zero pad when formatting it if necessary.

Resolves: #1222

funcs/func_callerid.c

index e215f16e43a3fe12e6220ae12436ac85d2999c47..0f4399fc46c4248d8e9e3f67bc60070e33d95d4b 100644 (file)
@@ -1048,7 +1048,9 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
                                ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
                        }
                } else if (member.argc == 1 && !strcasecmp("ani2", member.subnames[0])) {
-                       snprintf(buf, len, "%d", ast_channel_caller(chan)->ani2);
+                       /* ANI2 is always formatted as two digits:
+                        * https://nanpa.com/numbering/ani-ii-digits */
+                       snprintf(buf, len, "%02d", ast_channel_caller(chan)->ani2);
                } else if (!strcasecmp("ani", member.subnames[0])) {
                        if (member.argc == 1) {
                                /* Setup as if user had given ani-num instead. */