Merge rgagnon's pedantic string changes (apps n-z) (bug #2038)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3429 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2004-07-14 07:34:34 +00:00
parent 4d32c46126
commit 872685d088
13 changed files with 384 additions and 363 deletions

View File

@@ -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)