diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-07-16 04:40:54 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-07-16 04:40:54 +0000 |
commit | af243f9bcaab1304ac9213252c8ca124e94530d8 (patch) | |
tree | 2b84082d8285faa07556cfce5ff7367d9a22a640 /channels/chan_phone.c | |
parent | 0324a6e8e15ec318b768e56302a9dbbf41aea376 (diff) |
Last set of strncpy/snprintf updates (bug #2049)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3446 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_phone.c')
-rwxr-xr-x | channels/chan_phone.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/channels/chan_phone.c b/channels/chan_phone.c index 536d3ef86..4828d05ef 100755 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -177,15 +177,16 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout) time(&UtcTime); localtime_r(&UtcTime,&tm); + memset(&cid, 0, sizeof(PHONE_CID)); if(&tm != NULL) { - sprintf(cid.month, "%02d",(tm.tm_mon + 1)); - sprintf(cid.day, "%02d", tm.tm_mday); - sprintf(cid.hour, "%02d", tm.tm_hour); - sprintf(cid.min, "%02d", tm.tm_min); + snprintf(cid.month, sizeof(cid.month), "%02d",(tm.tm_mon + 1)); + snprintf(cid.day, sizeof(cid.day), "%02d", tm.tm_mday); + snprintf(cid.hour, sizeof(cid.hour), "%02d", tm.tm_hour); + snprintf(cid.min, sizeof(cid.min), "%02d", tm.tm_min); } /* the standard format of ast->callerid is: "name" <number>, but not always complete */ if (!ast->callerid || ast_strlen_zero(ast->callerid)){ - strcpy(cid.name, DEFAULT_CALLER_ID); + strncpy(cid.name, DEFAULT_CALLER_ID, sizeof(cid.name) - 1); cid.number[0]='\0'; } else { char *n, *l; @@ -198,9 +199,9 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout) l = NULL; } if (l) - strncpy(cid.number, l, sizeof(cid.number)); + strncpy(cid.number, l, sizeof(cid.number) - 1); if (n) - strncpy(cid.name, n, sizeof(cid.name)); + strncpy(cid.name, n, sizeof(cid.name) - 1); } p = ast->pvt->pvt; @@ -734,7 +735,7 @@ static void phone_check_exception(struct phone_pvt *i) ioctl(i->fd, PHONE_CPT_STOP); i->dialtone = 0; if (strlen(i->ext) < AST_MAX_EXTENSION - 1) - strcat(i->ext, digit); + strncat(i->ext, digit, sizeof(i->ext) - strlen(i->ext) - 1); if (ast_exists_extension(NULL, i->context, i->ext, 1, i->callerid)) { /* It's a valid extension in its context, get moving! */ phone_new(i, AST_STATE_RING, i->context); |