Index: apps/app_striplsd.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_striplsd.c,v retrieving revision 1.3 diff -u -p -r1.3 app_striplsd.c --- apps/app_striplsd.c 22 Jun 2004 19:32:52 -0000 1.3 +++ apps/app_striplsd.c 13 Jul 2004 22:19:53 -0000 @@ -45,16 +45,27 @@ LOCAL_USER_DECL; static int striplsd_exec(struct ast_channel *chan, void *data) { - char newexten[AST_MAX_EXTENSION] = ""; - if (!data || !atoi(data)) { - ast_log(LOG_DEBUG, "Ignoring, since number of digits to strip is 0\n"); - return 0; - } - if (strlen(chan->exten) > atoi(data)) { - strncpy(newexten, chan->exten, strlen(chan->exten)-atoi(data)); - } - strncpy(chan->exten, newexten, sizeof(chan->exten)-1); - return 0; + char newexten[AST_MAX_EXTENSION] = ""; + int maxbytes = 0; + int stripcount = 0; + int extlen = strlen(chan->exten); + + maxbytes = sizeof(newexten) - 1; + if (data) { + stripcount = atoi(data); + } + if (!stripcount) { + ast_log(LOG_DEBUG, "Ignoring, since number of digits to strip is 0\n"); + return 0; + } + if (extlen > stripcount) { + if (extlen - stripcount <= maxbytes) { + maxbytes = extlen - stripcount; + } + strncpy(newexten, chan->exten, maxbytes); + } + strncpy(chan->exten, newexten, sizeof(chan->exten)-1); + return 0; } int unload_module(void)