From a07f2c930bef91db5f14f214183775ec1898f6de Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Thu, 18 Oct 2001 16:47:57 +0000 Subject: Version 0.1.10 from FTP git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@376 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_modem.c | 38 +++++++++++++++++++------------------- channels/chan_modem_aopen.c | 8 ++++---- channels/chan_modem_bestdata.c | 8 ++++---- channels/chan_oss.c | 18 +++++++++--------- channels/chan_phone.c | 20 ++++++++++---------- channels/chan_vofr.c | 18 +++++++++--------- 6 files changed, 55 insertions(+), 55 deletions(-) (limited to 'channels') diff --git a/channels/chan_modem.c b/channels/chan_modem.c index ea5757e2f..fb4f236e1 100755 --- a/channels/chan_modem.c +++ b/channels/chan_modem.c @@ -165,7 +165,7 @@ static int modem_call(struct ast_channel *ast, char *idest, int timeout) struct ast_modem_pvt *p; int ms = timeout; char rdest[80], *where, dstr[100]; - strncpy(rdest, idest, sizeof(rdest)); + strncpy(rdest, idest, sizeof(rdest)-1); strtok(rdest, ":"); where = strtok(NULL, ":"); if (!where) { @@ -245,7 +245,7 @@ int ast_modem_read_response(struct ast_modem_pvt *p, int timeout) do { res = ast_waitfor_n_fd(&p->fd, 1, &timeout, NULL); if (res < 0) { - strncpy(p->response, "(No Response)", sizeof(p->response)); + strncpy(p->response, "(No Response)", sizeof(p->response)-1); return -1; } /* get no more then buffer length */ @@ -257,7 +257,7 @@ int ast_modem_read_response(struct ast_modem_pvt *p, int timeout) /* if nothing in buffer, go back into timeout stuff */ if (errno == EWOULDBLOCK) break; /* return as error */ - strncpy(p->response, "(No Response)", sizeof(p->response)); + strncpy(p->response, "(No Response)", sizeof(p->response)-1); return -1; } /* save char */ @@ -281,7 +281,7 @@ int ast_modem_read_response(struct ast_modem_pvt *p, int timeout) } } } while(timeout > 0); - strncpy(p->response, "(No Response)", sizeof(p->response)); + strncpy(p->response, "(No Response)", sizeof(p->response)-1); return -1; } @@ -289,7 +289,7 @@ int ast_modem_expect(struct ast_modem_pvt *p, char *result, int timeout) { int res = -1; timeout *= 1000; - strncpy(p->response, "(No Response)", sizeof(p->response)); + strncpy(p->response, "(No Response)", sizeof(p->response)-1); do { res = ast_waitfor_n_fd(&p->fd, 1, &timeout, NULL); if (res < 0) { @@ -363,7 +363,7 @@ static int modem_setup(struct ast_modem_pvt *p, int baudrate) ast_log(LOG_WARNING, "Modem did not provide identification\n"); return -1; } - strncpy(identity, p->response, sizeof(identity)); + strncpy(identity, p->response, sizeof(identity)-1); ast_modem_trim(identity); if (ast_modem_expect(p, "OK", ECHO_TIMEOUT)) { ast_log(LOG_WARNING, "Modem did not provide identification\n"); @@ -493,11 +493,11 @@ struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state) tmp->pvt->answer = modem_answer; tmp->pvt->read = modem_read; tmp->pvt->write = modem_write; - strncpy(tmp->context, i->context, sizeof(tmp->context)); + strncpy(tmp->context, i->context, sizeof(tmp->context)-1); if (strlen(i->cid)) tmp->callerid = strdup(i->cid); if (strlen(i->language)) - strncpy(tmp->language,i->language, sizeof(tmp->language)); + strncpy(tmp->language,i->language, sizeof(tmp->language)-1); i->owner = tmp; ast_pthread_mutex_lock(&usecnt_lock); usecnt++; @@ -677,9 +677,9 @@ static struct ast_modem_pvt *mkif(char *iface) free(tmp); return NULL; } - strncpy(tmp->language, language, sizeof(tmp->language)); - strncpy(tmp->msn, msn, sizeof(tmp->msn)); - strncpy(tmp->dev, iface, sizeof(tmp->dev)); + strncpy(tmp->language, language, sizeof(tmp->language)-1); + strncpy(tmp->msn, msn, sizeof(tmp->msn)-1); + strncpy(tmp->dev, iface, sizeof(tmp->dev)-1); /* Maybe in the future we want to allow variable serial settings */ stty(tmp); @@ -701,8 +701,8 @@ static struct ast_modem_pvt *mkif(char *iface) tmp->dialtype = dialtype; tmp->mode = gmode; memset(tmp->cid, 0, sizeof(tmp->cid)); - strncpy(tmp->context, context, sizeof(tmp->context)); - strncpy(tmp->initstr, initstr, sizeof(tmp->initstr)); + strncpy(tmp->context, context, sizeof(tmp->context)-1); + strncpy(tmp->initstr, initstr, sizeof(tmp->initstr)-1); tmp->next = NULL; tmp->obuflen = 0; @@ -721,7 +721,7 @@ static struct ast_channel *modem_request(char *type, int format, void *data) struct ast_modem_pvt *p; struct ast_channel *tmp = NULL; char dev[80]; - strncpy(dev, (char *)data, sizeof(dev)); + strncpy(dev, (char *)data, sizeof(dev)-1); strtok(dev, ":"); oldformat = format; /* Search for an unowned channel */ @@ -811,17 +811,17 @@ int load_module() } else if (!strcasecmp(v->name, "stripmsd")) { stripmsd = atoi(v->value); } else if (!strcasecmp(v->name, "type")) { - strncpy(mtype, v->value, sizeof(mtype)); + strncpy(mtype, v->value, sizeof(mtype)-1); } else if (!strcasecmp(v->name, "initstr")) { - strncpy(initstr, v->value, sizeof(initstr)); + strncpy(initstr, v->value, sizeof(initstr)-1); } else if (!strcasecmp(v->name, "dialtype")) { dialtype = toupper(v->value[0]); } else if (!strcasecmp(v->name, "context")) { - strncpy(context, v->value, sizeof(context)); + strncpy(context, v->value, sizeof(context)-1); } else if (!strcasecmp(v->name, "msn")) { - strncpy(msn, v->value, sizeof(msn)); + strncpy(msn, v->value, sizeof(msn)-1); } else if (!strcasecmp(v->name, "language")) { - strncpy(language, v->value, sizeof(language)); + strncpy(language, v->value, sizeof(language)-1); } v = v->next; } diff --git a/channels/chan_modem_aopen.c b/channels/chan_modem_aopen.c index f93fe0b67..80a1402f9 100755 --- a/channels/chan_modem_aopen.c +++ b/channels/chan_modem_aopen.c @@ -54,7 +54,7 @@ static int aopen_setdev(struct ast_modem_pvt *p, int dev) return -1; } ast_modem_trim(p->response); - strncpy(cmd, p->response, sizeof(cmd)); + strncpy(cmd, p->response, sizeof(cmd)-1); if (ast_modem_expect(p, "OK", 5)) { ast_log(LOG_WARNING, "Modem did not respond properly\n"); return -1; @@ -344,17 +344,17 @@ static char *aopen_identify(struct ast_modem_pvt *p) char rev[80]; ast_modem_send(p, "AT#MDL?", 0); ast_modem_read_response(p, 5); - strncpy(mdl, p->response, sizeof(mdl)); + strncpy(mdl, p->response, sizeof(mdl)-1); ast_modem_trim(mdl); ast_modem_expect(p, "OK", 5); ast_modem_send(p, "AT#MFR?", 0); ast_modem_read_response(p, 5); - strncpy(mfr, p->response, sizeof(mfr)); + strncpy(mfr, p->response, sizeof(mfr)-1); ast_modem_trim(mfr); ast_modem_expect(p, "OK", 5); ast_modem_send(p, "AT#REV?", 0); ast_modem_read_response(p, 5); - strncpy(rev, p->response, sizeof(rev)); + strncpy(rev, p->response, sizeof(rev)-1); ast_modem_trim(rev); ast_modem_expect(p, "OK", 5); snprintf(identity, sizeof(identity), "%s Model %s Revision %s", mfr, mdl, rev); diff --git a/channels/chan_modem_bestdata.c b/channels/chan_modem_bestdata.c index 59fbca11c..a360e32fd 100755 --- a/channels/chan_modem_bestdata.c +++ b/channels/chan_modem_bestdata.c @@ -189,7 +189,7 @@ static struct ast_frame *bestdata_handle_escape(struct ast_modem_pvt *p, char es char res[1000]; if (ast_modem_read_response(p, 5)) break; - strncpy(res, p->response, sizeof(res)); + strncpy(res, p->response, sizeof(res)-1); ast_modem_trim(res); if (!strncmp(res,"\020.",2)) break; if (!strncmp(res,"NAME",4)) strcpy(name,res + 7); @@ -419,17 +419,17 @@ static char *bestdata_identify(struct ast_modem_pvt *p) char rev[80]; ast_modem_send(p, "AT+FMM", 0); ast_modem_read_response(p, 5); - strncpy(mdl, p->response, sizeof(mdl)); + strncpy(mdl, p->response, sizeof(mdl)-1); ast_modem_trim(mdl); ast_modem_expect(p, "OK", 5); ast_modem_send(p, "AT+FMI", 0); ast_modem_read_response(p, 5); - strncpy(mfr, p->response, sizeof(mfr)); + strncpy(mfr, p->response, sizeof(mfr)-1); ast_modem_trim(mfr); ast_modem_expect(p, "OK", 5); ast_modem_send(p, "AT+FMR", 0); ast_modem_read_response(p, 5); - strncpy(rev, p->response, sizeof(rev)); + strncpy(rev, p->response, sizeof(rev)-1); ast_modem_trim(rev); ast_modem_expect(p, "OK", 5); snprintf(identity, sizeof(identity), "%s Model %s Revision %s", mfr, mdl, rev); diff --git a/channels/chan_oss.c b/channels/chan_oss.c index fab41ed14..3959cda13 100755 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -727,11 +727,11 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state) tmp->pvt->indicate = oss_indicate; tmp->pvt->fixup = oss_fixup; if (strlen(p->context)) - strncpy(tmp->context, p->context, sizeof(tmp->context)); + strncpy(tmp->context, p->context, sizeof(tmp->context)-1); if (strlen(p->exten)) - strncpy(tmp->exten, p->exten, sizeof(tmp->exten)); + strncpy(tmp->exten, p->exten, sizeof(tmp->exten)-1); if (strlen(language)) - strncpy(tmp->language, language, sizeof(tmp->language)); + strncpy(tmp->language, language, sizeof(tmp->language)-1); p->owner = tmp; tmp->state = state; ast_pthread_mutex_lock(&usecnt_lock); @@ -895,7 +895,7 @@ static int console_dial(int fd, int argc, char *argv[]) mye = exten; myc = context; if (argc == 2) { - strncpy(tmp, argv[1], sizeof(tmp)); + strncpy(tmp, argv[1], sizeof(tmp)-1); strtok(tmp, "@"); tmp2 = strtok(NULL, "@"); if (strlen(tmp)) @@ -904,8 +904,8 @@ static int console_dial(int fd, int argc, char *argv[]) myc = tmp2; } if (ast_exists_extension(NULL, myc, mye, 1, NULL)) { - strncpy(oss.exten, mye, sizeof(oss.exten)); - strncpy(oss.context, myc, sizeof(oss.context)); + strncpy(oss.exten, mye, sizeof(oss.exten)-1); + strncpy(oss.context, myc, sizeof(oss.context)-1); hookstate = 1; oss_new(&oss, AST_STATE_UP); } else @@ -972,11 +972,11 @@ int load_module() else if (!strcasecmp(v->name, "silencethreshold")) silencethreshold = atoi(v->value); else if (!strcasecmp(v->name, "context")) - strncpy(context, v->value, sizeof(context)); + strncpy(context, v->value, sizeof(context)-1); else if (!strcasecmp(v->name, "language")) - strncpy(language, v->value, sizeof(language)); + strncpy(language, v->value, sizeof(language)-1); else if (!strcasecmp(v->name, "extension")) - strncpy(exten, v->value, sizeof(exten)); + strncpy(exten, v->value, sizeof(exten)-1); v=v->next; } ast_destroy(cfg); diff --git a/channels/chan_phone.c b/channels/chan_phone.c index 27de1daac..c481abb99 100755 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -599,11 +599,11 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte tmp->pvt->read = phone_read; tmp->pvt->write = phone_write; tmp->pvt->exception = phone_exception; - strncpy(tmp->context, context, sizeof(tmp->context)); + strncpy(tmp->context, context, sizeof(tmp->context)-1); if (strlen(i->ext)) - strncpy(tmp->exten, i->ext, sizeof(tmp->exten)); + strncpy(tmp->exten, i->ext, sizeof(tmp->exten)-1); if (strlen(i->language)) - strncpy(tmp->language, i->language, sizeof(tmp->language)); + strncpy(tmp->language, i->language, sizeof(tmp->language)-1); if (strlen(i->callerid)) tmp->callerid = strdup(i->callerid); i->owner = tmp; @@ -934,14 +934,14 @@ static struct phone_pvt *mkif(char *iface, int mode, int txgain, int rxgain) tmp->lastinput = -1; tmp->ministate = 0; memset(tmp->ext, 0, sizeof(tmp->ext)); - strncpy(tmp->language, language, sizeof(tmp->language)); - strncpy(tmp->dev, iface, sizeof(tmp->dev)); - strncpy(tmp->context, context, sizeof(tmp->context)); + strncpy(tmp->language, language, sizeof(tmp->language)-1); + strncpy(tmp->dev, iface, sizeof(tmp->dev)-1); + strncpy(tmp->context, context, sizeof(tmp->context)-1); tmp->next = NULL; tmp->obuflen = 0; tmp->dialtone = 0; tmp->cpt = 0; - strncpy(tmp->callerid, callerid, sizeof(tmp->callerid)); + strncpy(tmp->callerid, callerid, sizeof(tmp->callerid)-1); tmp->txgain = txgain; ioctl(tmp->fd, PHONE_PLAY_VOLUME, tmp->txgain); tmp->rxgain = rxgain; @@ -1044,9 +1044,9 @@ int load_module() } else if (!strcasecmp(v->name, "silencesupression")) { silencesupression = ast_true(v->value); } else if (!strcasecmp(v->name, "language")) { - strncpy(language, v->value, sizeof(language)); + strncpy(language, v->value, sizeof(language)-1); } else if (!strcasecmp(v->name, "callerid")) { - strncpy(callerid, v->value, sizeof(callerid)); + strncpy(callerid, v->value, sizeof(callerid)-1); } else if (!strcasecmp(v->name, "mode")) { if (!strncasecmp(v->value, "di", 2)) mode = MODE_DIALTONE; @@ -1057,7 +1057,7 @@ int load_module() else ast_log(LOG_WARNING, "Unknown mode: %s\n", v->value); } else if (!strcasecmp(v->name, "context")) { - strncpy(context, v->value, sizeof(context)); + strncpy(context, v->value, sizeof(context)-1); } else if (!strcasecmp(v->name, "format")) { if (!strcasecmp(v->value, "g723.1")) { prefformat = AST_FORMAT_G723_1; diff --git a/channels/chan_vofr.c b/channels/chan_vofr.c index 836c1de34..00cb19bb3 100755 --- a/channels/chan_vofr.c +++ b/channels/chan_vofr.c @@ -823,13 +823,13 @@ static struct ast_channel *vofr_new(struct vofr_pvt *i, int state) tmp->pvt->write = vofr_write; tmp->pvt->fixup = vofr_fixup; if (strlen(i->language)) - strncpy(tmp->language, i->language, sizeof(tmp->language)); + strncpy(tmp->language, i->language, sizeof(tmp->language)-1); i->owner = tmp; ast_pthread_mutex_lock(&usecnt_lock); usecnt++; ast_pthread_mutex_unlock(&usecnt_lock); ast_update_use_count(); - strncpy(tmp->context, i->context, sizeof(tmp->context)); + strncpy(tmp->context, i->context, sizeof(tmp->context)-1); if (state != AST_STATE_DOWN) { if (ast_pbx_start(tmp)) { ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name); @@ -1050,7 +1050,7 @@ static struct vofr_pvt *mkif(char *type, char *iface) #ifdef OLD_SANGOMA_API /* Prepare sockaddr for binding */ memset(&tmp->sa, 0, sizeof(tmp->sa)); - strncpy(tmp->sa.spkt_device, iface, sizeof(tmp->sa.spkt_device)); + strncpy(tmp->sa.spkt_device, iface, sizeof(tmp->sa.spkt_device)-1); tmp->sa.spkt_protocol = htons(0x16); tmp->sa.spkt_family = AF_PACKET; if (bind(tmp->s, (struct sockaddr *)&tmp->sa, sizeof(struct sockaddr))) { @@ -1059,8 +1059,8 @@ static struct vofr_pvt *mkif(char *type, char *iface) memset(&tmp->sa, 0, sizeof(tmp->sa)); tmp->sa.sll_family = AF_WANPIPE; tmp->sa.sll_protocol = htons(ETH_P_IP); - strncpy(tmp->sa.sll_device, iface, sizeof(tmp->sa.sll_device)); - strncpy(tmp->sa.sll_card, "wanpipe1", sizeof(tmp->sa.sll_card)); + strncpy(tmp->sa.sll_device, iface, sizeof(tmp->sa.sll_device)-1); + strncpy(tmp->sa.sll_card, "wanpipe1", sizeof(tmp->sa.sll_card)-1); tmp->sa.sll_ifindex = 0; if (bind(tmp->s, (struct sockaddr *)&tmp->sa, sizeof(struct wan_sockaddr_ll))) { #endif @@ -1088,8 +1088,8 @@ static struct vofr_pvt *mkif(char *type, char *iface) tmp->dlcih = 0; tmp->cid = 1; tmp->ringgothangup = 0; - strncpy(tmp->language, language, sizeof(tmp->language)); - strncpy(tmp->context, context, sizeof(tmp->context)); + strncpy(tmp->language, language, sizeof(tmp->language)-1); + strncpy(tmp->context, context, sizeof(tmp->context)-1); /* User terminations are game for outgoing connections */ if (!strcasecmp(type, "user")) tmp->outgoing = 1; @@ -1169,9 +1169,9 @@ int load_module() return -1; } } else if (!strcasecmp(v->name, "context")) { - strncpy(context, v->value, sizeof(context)); + strncpy(context, v->value, sizeof(context)-1); } else if (!strcasecmp(v->name, "language")) { - strncpy(language, v->value, sizeof(language)); + strncpy(language, v->value, sizeof(language)-1); } v = v->next; } -- cgit v1.2.3